Dynamic naming of objects in list

200 Views Asked by At

I'm using the write_xlsx function from the writexl package. I want to use the list function to dynamically name the tabs in the Excel files I am writing.

Code I have already tried:

Tab_Name = paste0(Input$IndicatorID_RC[i])

Pulls through the IndicatorID_RC from an input file which is the ID I want to use as the name of the tab in the output Excel file.

write_xlsx(list(Tab_Name = IndicatorData), path = paste0(Input$IndicatorID_RC[i],".xlsx"))

Create a list where Tab_Name is the name of the data frame IndicatorData and thus the name of the tab.

When I open the output Excel file, the tab name is Tab_Name and not IndicatorID_RC.

This code is on a loop starting with i = 1.

I'm sure there's a simple answer, any ideas?

0

There are 0 best solutions below