Write list of data.frames to separate CSV files with lapply

前端 未结 3 1780
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 02:11

The question says it all - I want to take a list object full of data.frames and write each data.frame to a separate .csv file where the name of the .csv file corresponds to

3条回答
  •  余生分开走
    2020-11-29 02:34

    Try this:

    sapply(names(df.daily), 
     function (x) write.table(df.daily[[x]], file=paste(x, "txt", sep=".") )   )
    

    You should see the names ("1", "2", "3") spit out one by one, but the NULLs are the evidence that the side-effect of writing to disk files was done. (Edit: changed [] to [[]].)

提交回复
热议问题