I have 18 data set from 2002-2020 that I want to add a year column to before I bind them all together. I created this function:
year_add <- function(x,y) {mutate(x, Year =y)} ## adds the year variable to data frame
which works perfectly for one data frame, but I don't know how to run it through a list of all 18 data sets. I have tried for loops and lapply, but can't seem to get any of them to work... Any suggestions?
FYI, to run the code on one data set, I simply put:
year_add(data2002, "2002")