I'm trying to export multiple files .csv
to R through the lapply
function. These files are within a list. I've 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, in fact) 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 a response with lapply
, because with for
I can do the export. This way, it's more of a curiosity to know why lapply
does not work.