How do I write multiple CSV files from a list of data frames?

前端 未结 2 1482
一生所求
一生所求 2021-02-04 19:28

I have a list with two data frames. I want to loop thru the list and write a CSV for each data frame and name it after the data frame name.

library(ggplot2)
myLi         


        
2条回答
  •  迷失自我
    2021-02-04 20:20

    You can also use mapply:

    myList <- list(diamonds = diamonds, 
                   cars = cars)
    mapply(write.csv, myList, file=paste0(names(myList), '.csv'))
    

提交回复
热议问题