im trying to make a function that takes two files, say x and y, and returns a xls book, the function would create a number of sheets with the names selected from the x file, x would look like this
sol
Orden
1 Z169
2 Z170
3 Z175
now, with the sheets created, it would write a data taken from the second (the y) file, the y file looks like this
base
Orden Dependencia
1 Z169 TRæNSITO
2 Z170 TRæNSITO
3 Z171 TRæNSITO
4 Z172 TRæNSITO
5 Z173 POLICIA
6 Z174 TRæNSITO
7 Z175 POLICIA
as far as i get, i have this code(in it minimal, complete, verifiable form, or it is not?)
autoform <- function(x,y){
## create wordbook
wb <- createWorkbook()
## create work sheets
for (i in 1:length(x[,1])){
if(isTRUE(x[i,1] %in% y[,1])){
addWorksheet(wb, x[i,1])
##editing the sheet
writeData(wb, x[i,1], y[i,2], startCol = 8, startRow = 6,rowNames = TRUE )
}
}
## save file
saveWorkbook(wb, "marth/javi/supertest.xlsx", overwrite = TRUE)
}
when i try to use the autoform(x,y) i get this error:
> autoform(sol, base)
Error in nchar(sheetName) : 'nchar()' requires a character vector
i was hopping someone can explain me why is this error an how to solve it, tank u for reading