2011年9月9日星期五

write list object to a text file

http://stackoverflow.com/questions/7351049/write-csv-a-list-of-unequally-sized-data-frames 
 
outputs <- list() 
outputs$fivenum <- fivenum(rnorm(100))
outputs$summary <- as.data.frame(as.vector(summary(rnorm(100))))

tmp <- lapply(outputs, as.data.frame)

# can not work
write.csv(tmp, file="Output.csv",append=T)

# workable
sapply(tmp, write.table, file="Output.csv", append=TRUE, sep=",")

没有评论:

发表评论