How to automate creating excel spreadsheets in R

Asked

Viewed 58 times

1

Good morning, I find myself in a problem, that although it seems very simple to solve, I can not find a solution without manually making the creation of all, so let’s go:

library(stringr)
library("xlsx")

lista <- c("L1","L2","L3")
listaData <- c(L1,L2,L3)
##essa linha seria para pegar os dados  l1 l2 l3 do servidor, por isso ocultei, ela esta funcional.
f.pasta <- str_c("C:/Users/.../",lista,".xlsx")
for(idx in (length(listaData))){
idx = 1
write.xlsx( **eu preciso de uma solução para colocar a listaData aqui**, file = fpasta[idx])
}

the problem is: when I place listData in bold area it already pulls direct date, if I try to traverse the vector (ex: listData[1]) it will catch the first row of the FUSAO of the 3 tables (L1L2L3) Since I have to do this 600 times, it will become a problem if I don’t automate... I expect a help <3 ty

What would be a possible solution but I do not know how to do: The Datebook is a TYPE that only calls the name of the variable L1 and not the data table. (I don’t know if it is possible to do).

  • Try mapply(write.xlsx, listaData, f.pasta). Looks like that’s it, keeps every table of listaData in each file of f.pasta.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.