0

As I'm dealing with a huge dataset I had to split my data into different buckets. Thus, I want to save some interim results in a csv to recall it later. However, my datafile contains some columns with lists, which according to R can not be exported (see snapshot). Do you guys know a simple way for a R newbie to make this work?

Thank you so much!

Snapshot of dataset

Brian
  • 7,900
  • 1
  • 27
  • 41
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Please don't post image of data or code. – MrFlick Dec 13 '21 at 20:22
  • Instead of CSV, use the `.rdata` file format with `save(...)` or `saveRDS(...)`. There's no need to parse anything, it's the fastest (or among the fastest) for write/read performance in data for R, and it preserves (nearly perfectly) the classes, attributes, and structure of the object. It doesn't matter if it's a frame with list-columns or something else. – r2evans Dec 13 '21 at 21:04

2 Answers2

1

I guess the best way to solve your problem is switching to a more apropriate file format. I recomend using write_rds() from the readr package, which creates .rds files. The files you create with readr::write_rds('your_file_path') can be read in with readr::read_rds('your_file_path').

The base R functions are saveRDS() and readRDS() and the functions mentioned earlier form the readr are just wrappers with some convience features.

DPH
  • 4,244
  • 1
  • 8
  • 18
0

Just right click, then choose new csv to the folder where you want to save your work. Then set the separator of the csv to a comma.

Input all data in column form. You can later make it a matrix in your R program.

InverniE
  • 598
  • 1
  • 7
  • 21
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 13 '21 at 22:27