R - Add columns to dataframes in list by looping through elements in a vector
问题 I am working with several datasets that measure the same variables over many years. I am trying to add a year variable to each dataset, but more generally I want to loop through elements in a vector and add each as a new column in a list of dataframes. This question was similar to mine but I want to iteratively add each element in a vector to the corresponding dataframe as a new column: R - New variables over several data frames in a loop Here's sample data: year <- c(1:3) data1 <- data.frame