I have a three dataframes with 77 variables. They are all the same, they only differ in years (2014, 2015, 2016).
I want to merge them, but all the colnames are exactly the same, So I don't know which values belong to 2014, 2015 or 2015.
I want to solve this by adding the year to all colnames in the three dataframes.
So now I have:
df_2014:
a|b|c
1|2|3
df_2015
a|b|c|
4|5|6|
df_2016
a|b|c|
7|8|9|
I would like to have:
df_2014:
a(2014)|b(2014)|c(2014)
1|2|3
df_2015:
a(2015)|b(2015)|c(2015)|
4|5|6|
df_2016:
a(2016)|b(2016)|c(2016)|
7|8|9|
Does anyone know if I can do this with a loop or another function? Otherwise I need to rename the colnames 231 times ;)
thanks, Arnand
You could use setNames. For instance: