Hi, all.
I would like to make seperate datasets for the years 2015, 2016 and 2017. The way I did it for one year is like the following:
Merging datasets:
df_2017<- data.frame(cars$2017
, bikes$2017
, motorcycle$2017
, trucks$2017
, cars_p$2017
,
bikes_p$2017
, motorcycle_p$2017
, truck_p$2017
)
cars, bikes, motorcycle etc are other small dataframes that I would like to extract information for only one particular year and gather the information from all the different datasets into one. So the gathered data.frame for 2017 would be df_2017. The name of the columns are the years (2015, 2016, 2017)
Does anyone know how I can implement this in a FOR-loop (or by vectorization) so I dont have to write the code over and over again?
Thanks!