如何让sink()函数来打印csv

时间:2018-04-18 14:55:44

标签: r

The output of the following R 
    # Factor loading
    cat("Factor loading \n \n")
    Personality_factor$loadings
    sink()

Factor loading 


Loadings:
                               MR2    MR3    MR4    MR1    MR5    MR6   
talkative                       0.141  0.124 -0.712        -0.104  0.147
finds.fault                            0.192                0.587  0.130
does.a.thorough.job             0.680                              0.105
depressed                      -0.138  0.570  0.124         0.104 -0.123
original                        0.118 -0.112 -0.128  0.665        -0.124
reserved                        0.106  0.116  0.684                     
helpful                         0.342        -0.139        -0.363       
careless                       -0.607  0.150                       0.209
relaxed                               -0.657  0.118                0.120


How can I print output in CSV like 
,MR2,MR3,MR4,MR1,MR5,MR6   
talkative,0.141,0.124,-0.712,-0.104,0.147
finds.fault,0.192,,,0.587,0.130
does.a.thorough.job,0.680,,,,0.105,0.130
depressed,-0.138,0.570,0.124,,0.104,-0.123
......

1 个答案:

答案 0 :(得分:0)

如果您的数据是data.frame,您可以轻松地将其保存到工作目录中:

cars
write.csv(cars, file = "cars.csv")

您可以使用setwd()

设置工作目录