I am brand new to R so if I'm thinking about this completely wrong feel free to tell me. I have a series of imported dataframes on power plants, one of each year (Plant1987, Plant1988 etc...) that I am trying to combine ultimately into one data frame. Prior to doing so, I'd like to add a "year" variable to each dataframe. I could do this for each individual dataframe, but would like to formalize it and do it in one step. I know how to do it in stata, but I'm struggling here.
I was thinking something along the lines of:
for (y in 1987:2008) {
paste("Plant",y,sep="")$year <- y
}
which doesn't work because paste is obviously not the right function. Is there a smart, quick way to do this? Thanks