I have been splitting up dataframes and writing them to txt files in R, but now I've found out that they need to be written to xlsx files. I installed the xlsx package and modified my loop, but it doesn't work anymore. I get "Error in [[.default(dots[[2L]], 1L) : subscript out of bounds".
Here is the loop:
trts<-vector("list", length=6)
trt<-as.character(c("CC", "CCW", "C2", "S2", "PF", "P"))
for(i in 1:6){
trts[[i]]<-co2[co2$trt == trt[i],]
write.xlsx(trts[[i]], paste(trt[i], "CO2", "xlsx", sep="."))
Here is the data (my df is co2): Split this.
What's the deal?
[[.default(dots[[2L]], 1L) : subscript out of bounds".List[[7]]for alistoflength < 7or something. Try addingprint(i)as a line in your loop and see if you can figure out which one is giving you the problem.print(3)andprint(4).