2
I’m trying to export multiple files .csv
in R through the function lapply
. These files are within a list. I tried the following settings:
lapply(list,function(x)
write.csv2(list$x,paste0(x),row.names=FALSE))
lapply(seq_along(list),function(x)
write.csv2(list$x,paste0(x),row.names=FALSE))
among others, which returned error messages.
The dput
(a list, actually) follows below:
lista=structure(list(dados1 = structure(list(aa = c(1, 2, 3, 4, 5,
6, 7), bb = c(1, 2, 3, 4, 5, 6, 7)), .Names = c("aa", "bb"), row.names = c(NA,
-7L), class = "data.frame"), dados2 = structure(list(cc = c(1,
2, 3, 4, 5, 6, 7), dd = c(1, 2, 3, 4, 5, 6, 7)), .Names = c("cc",
"dd"), row.names = c(NA, -7L), class = "data.frame")), .Names = c("dados1",
"dados2"))
I need an answer with lapply
, because with for
I can do the export. This way, it is more a curiosity to know why of lapply
not work.