Friday, April 19, 2013

Saving data frames in R

If 'df' is your data frame,
save(df,file="yourfile.rdf",ascii=TRUE)
save the data frame in to a .rdf file which is readable. Although the file as lot more data than you might want, loading the file back into R irons out any wrinkles.
load("yourfile.rdf")
http://stackoverflow.com/questions/8345759/how-to-save-a-data-frame-in-r

Edit Jan 2014
If however you really want to avoid additional lines in the saved file, try the following:
write.table(df,filename,row.names=FALSE,col.names=FALSE)
This should produce a clean file with your data in a neat column.

No comments:

Post a Comment