I need to write an excel file with multiple sheets named "Cases", "Coordinators", "Contacts"
I have checked the class of each--e.g., class(Cases)--and the result in each case is:
class(Cases)
[1] "tbl_df" "tbl" "data.frame"
I combine these dfs into a list called "compiledData" as follows:
compiledData <- c(Cases, Coordinators, Contacts)
and checked class of compiledData as follows:
class(compiledData)
[1] "list"
So, I am confused as to why the following code results in the following error:
write_xlsx(compiledData, "FileName.xlsx")
Error in write_xlsx(compiledData, "FileName.xlsx") :
Argument x must be a data frame or list of data frames
Any assistance would be greatly appreciated. I have been searching for two days for a solution, but have not found an answer. Apologies in advance if a solution has already been posted and I've not seen it.
One update: I changed compiledData <- c(Cases, Coordinators, Contacts)
to:
compiledData <- list(Cases, Coordinators, Contacts)
and the Excel file is now being created without error. My new problem is that the worksheets in the excel file are not labeled "Cases", "Coordinators", "Contacts"--they are Sheet1, Sheet2, Sheet3