Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does R have a way of preserving column format when exporting a data frame?

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?

like image 852
jmi Avatar asked Mar 12 '23 05:03

jmi


1 Answers

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

like image 51
Mhairi McNeill Avatar answered Apr 06 '23 15:04

Mhairi McNeill