Should be a simple task, but I’m so far unable to find how.
Sample data:
var1 <- list('2003' = 1:3, '2004' = c(4:3), '2005' = c(6,4,1), '2006' = 1:4 )
Unsuccessful code:
library("XLConnect")
wb <- loadWorkbook("var1.xlsx", create = TRUE)
wb <- lapply(var1, function(x) {createSheet(wb, name = x)})
saveWorkbook(wb)
A more concise version of @Andrie’s answer, since the XLConnect API is vectorized: