I have some code in R that invites a user to put in a year between 2010 and 2021.
chosen.year <- readline(promt = "choose year between 2010 and 2021:")
y.chosen.year <- paste("y", chosen.year)
year.input <- gsub(" ", "", y.chosen.year, fixed = TRUE)
The output that is stored in year.input is for e.g. 2015: y2015.
I have a dataframe for each year between 2010 and 2021 that is called y2010, y2011 etc.
Is it possible to later use year.input in another function that would otherwhise require me to write y2015 (so that the user can choose a year that will be used later  on)?
Example:
myspdf2 <- merge(myspdf1, year.input, by.x "abc", by .y "def")
Instead of:
myspdf2 <- merge(myspdf1, y2015, by.x "abc", by .y "def")
I tried the method above but it did not work.
 
    