0

I have a dataframe in R (points_t3) with 20 million records and I am looking to split into even chuncks in a same order and write a .csv file for each chunk. I was able to split the data using the below code:

n = 20
split(points_t3, factor(sort(rank(row.names(points_t3))%%n)))

Any suggestions on how to use this split and able to write data into 20 separate csv files in the directory path defined in R. Thanks,

user438383
  • 5,716
  • 8
  • 28
  • 43
Neel
  • 31
  • 6
  • 2
    Use `lapply` to write each element of the list returned by `split` to the required .csv file. – Limey May 31 '22 at 15:04
  • 1
    Thank you both for the reply. The tips and the linked helped. I used this that seems to be working perfectly and getting me output in 20 csv files: lapply(names(points_t3), function(x){ write_csv(points_t3[[x]], paste(x, ".csv", sep = "")) }) – Neel May 31 '22 at 15:50

0 Answers0