I would like to save different data frames in R that is titled with a year. My approach so far has been to do like this:
year <- 2020
write.table(df, file = "D:/.../.../df_year.xlsx")
If I am using the above approach, I am ending with a data frame called df_year.xlsx, but I want it to be named "df_2020.xlsx".
>Solution :
There is the glue package (Part of the tidyverse) for this:
library(stringr)
year <- 2020
write.table(df, file = str_glue("D:/.../.../df_{year}.xlsx"))
Alternatively, one can use paste:
write.table(df, file = paste0("D:/.../.../df_", year, ".xlsx"))