0

i have to save at least three diferent lists in trhee diferent execel files at the same time, in this case the name of the lists that will bacame files change only in the years, like this:

fluminense_2011
fluminense_2012
fluminense_2013

with this pointed i want to make a loop that can automate the process of saving the lists on excel files, but i dont know how to make that. I was tryng to save the lists in one vector and than triyng to aplly the follow formula:

 data_names <- c("fluminense_2011", "fluminense_2012" , "fluminense_2014")
    for(i in 2:length(data_names)) {
  write.xlsx2(get(data_names[i]), paste0(my_path, "fluminense_bruto"),
              row.names = FALSE, sheetName = data_names[i], append = TRUE)}

the problem is that i dont know how to change de formula above to adpapt for my problem

1 Answers1

0

take a look at this answer.

dfs <- c('iris','cars')
lapply(dfs,function(x) xlsx::write.xlsx2(eval(as.symbol(x)), paste0(my_path, x,".xlsx"), row.names = FALSE, sheetName = x, append = TRUE))
   
Eric
  • 1,381
  • 9
  • 24