I have 15 tibbles that I want to export to a single XLSX workbook, with the sheetName for each set to be the same as the name of the tibble object. To export a single tibble, this works just fine:
library(xlsx)
my_tibble1 %>%
write.xlsx("output_filename.xlsx",
sheetName = "my_tibble1",
append = TRUE)
However, there are enough of these tibbles that writing all that out for each one is time-consuming. So, I wrote a function:
output_expediter <- function(df, output_filename) {
write.xlsx(df,
output_filename,
sheetName = deparse(substitute(df)),
append = TRUE)
This function successfully writes the tibble to a new sheet in the output workbook, BUT the sheetName is always a single period (".").
All the variable names used for the tibbles are limited to lowercase characters and underscores, and all of them are 31 or fewer characters long, so I don't think any of them violate XLSX format conventions. In the R console, running:
deparse(substitute(my_tibble1))
yields "my_tibble1" as expected.
Any ideas for why this is happening? Any possible workarounds, other than just typing out the names of each sheet?