将输出输入到Excel中 [英] Putting output in R into excel
问题描述
,所以基本上我得到这个输出:
[[1]
数字中位数
1 5
2 3
.. ...
[[2]]
数字中位数
1 6
2 4
....
[[3]]
编号中值
1 3
2 5
所以我基本上得到这个输出....直到[[7]]
我尝试使用此代码在excel中传输此输出
write .csv(cbind(data),data1.csv)
我得到这种类型的输出:
list(c(Median = .......它列出行上的所有中位数
但是我想要保存数据,参考NOT ROWS
如果我只输入
write.csv(data,data1.csv )
我收到错误
参数意味着不同行数:157,179,178,180
解决方案正如Marius所说,您有一个列表
data.frames
,不能写入 .csv
文件。你需要做:
NewDataFrame< - do.call(rbind,YourList)
write.csv (NewDataFrame,Data.csv)
do.call
从列表
中的每个元素,并应用您告诉它的任何函数(在这种情况下 rbind
)给所有的人。
Guys I have a code that generates 2 columns of data (e.g Number, Median) which refers to a particular person...but I have taken samples of 7 people
so basically I get this output:
[[1]
Number Median
1 5
2 3
.....
[[2]]
Number Median
1 6
2 4
....
[[3]]
Number Median
1 3
2 5
So I basically get this output....up til [[7]]
I tried transferring this output in excel using this code
write.csv(cbind(data),"data1.csv")
and I get this type of output:
list(c(Median =.......It lists all the median on the rows
But I want it to save the data referring to the 'median' and 'Number' in columns NOT ROWS
If I just type
write.csv(data,"data1.csv")
I get an error
arguments imply differing number of rows: 157, 179, 178, 180
解决方案 As Marius said, you have a list
of data.frames
which can't be written to a .csv
file. You need to do:
NewDataFrame <- do.call("rbind", YourList)
write.csv(NewDataFrame, "Data.csv")
do.call
takes each of the elements from a list
and applies whatever function you tell it (in this case rbind
) to all of them.
这篇关于将输出输入到Excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!