Wednesday, June 19, 2013

Methods to save data frame in file in R

When you try to "save" your data set in a data frame object in R, you have several options:
Method
Pro
Con
Funcitons
Image the object in binary format
Fast, can keep object name and other environment information
R specific
save(df, file= "filename")
rm(df)
load("filename", .GlobalEnv)
Save in coded text
Full information, e.g. data mode
Size is big, can not exchange with other software
dump(c("df"),"filename")
newDf = source(“filename")$value
Export  to plain text
Human readable, and software exchangeable
May need to recast R types when read in
write.table()
read.table()
Export to other format
Software specific
Software specific
Write.X()
Read.X(), where X can be spss, sas,csv, excel

No comments:

Post a Comment