I am working in R.
I have two variables defined:
year_current <- 24
year_last <- 23
Currently I have a variable and it is defined like this:
SQL_flatfile_23_24 <- "[schema_24].[liverun_23_24]"
However I want it to update dynamically. I.e. when I update year_current and year_last, I don’t then need to update that line of code too.
I think it will have to have something to do with sym, or !! or :-, but I can’t get it to work!
sym(paste0("SQL_flatfile_", year_last, "_", year_current)) =
paste0("[schema_", year_current, "][liverun_", year_last, "_", year_current, "]")
The left hand side of this seems to run ok – i.e. it is not outputting as a string?
> sym(paste0("SQL_flatfile_", year_last, "_", year_current))
SQL_flatfile_2023_2024
But running the whole thing does not work…
Does anyone have any ideas?