4

I often export data.frame's in R but run into the problem when I try to import them back in, lose all of the formatting into date/numeric/logical/factor values and get it all back as character variables instead. It gets kind of old to have to run a cleaning/formatting script over and over again on the same file so I was wondering if there is a way or a parameter on write.table that allows one to conserve all of this?

jmi
  • 43
  • 4

2 Answers2

4

Use saveRDS and readRDS. These will save and load your data frames into exactly the same format.

Mhairi McNeill
  • 1,951
  • 11
  • 20
3

If it's tabular data, you can use the new feather format to save your data. That way you can even read it into Python without losing column type information.

RoyalTS
  • 9,545
  • 12
  • 60
  • 101