I'm trying to write data from my for loop to excel file in a way that the data is in one sheet. I've been using the xlsx library but for some reason adding the APPEND = TRUE doesn't do the trick. An example of what I've been trying to do:
write.xlsx("Info", "results.xlsx", sheetName="Info", col.names=TRUE, row.names=TRUE, append=FALSE)
for (i in 1:10) {
write.xlsx(i, "results.xlsx", sheetName="datasheet",col.names=TRUE, row.names=TRUE, append=TRUE)
}
This only works to write the first loop results, after that I get an error telling me that there's already a sheet with the same name and it won't append the result to the sheet. How should I approach this?