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)
myList <- list(diamonds, cars)
for(i in mylist){
write.csv(df, paste0(names(myList[i]),".csv"))
}
But this only outputs one CSV file names .csv
with data from cars
.
How do I fix this so I have two CSVs named diamonds.csv
and cars.csv
with the correct data in each?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…