I have some data frames I created in R and I want to export them to excel, but R doesn't recognize the dataframe already exists and it creates the file with the sheets but no data. So using the code below I get Total_Arizona spreadsheet but there is no data in it. Total_Arizona is a dataframe in global environment.
`Monthly_Report <- createWorkbook()
for (i in levels(Data$State)) {
addWorksheet(Monthly_Report, paste0("Total_", i))
writeData(Monthly_Report, sheet = paste0("Total_", i), x=paste0("Total_", i), startCol = 1,
startRow = 1)}
saveWorkbook(Monthly_Report, "Monthly_Report.xlsx")`