I have two dataframes that are .csv files looking like this :
data <- data.frame(ID=c(205,206,207,308,310,400,401,35,36,90),
year=c(2015, 2015,2015,2015,2015, 2015, 2015, 2015,2015, 2015),
ghost=c(0,3,0.5,17.5,37.5,0,87.5,0,0,0),
pumkin=c(3,3,3,3,0,0,37.5,0,0,15),
pirate=c(3,3,3,3,0,0,37.5,0,87.5,3))
and the second one which has different observations of halloween costums for different years :
data1 <- data.frame(ID=c(1,12,13,14,15,16,17),
year=c(2017,2017,2017,2017,2017,2017,2017),
ghost=c(0,3,0.5,17.5,37.5,0,87.5),
mermaid=c(0.5,0.5,37.5,37.5,0,0.5,37.5))
What I would like to have, is one data frame that takes all the elements from both the dataframes which will have this form :
ID year ghost pumkin pirate mermaid
205 2015 0
206 2015 3
207 2015 0.5
308 2015 17.5
... ...
1 2017 0
12 2017 3
13 2017 0.5
The columns that were not present in one of the dataframe will be added and fill with zeros.
Is there any way to do this ? I've tried using merge() and join() and I was exploring the possibility to use dplyr as well to manipulate my dataframes but it feels like there are two issues in my problem and no simple ways to do what i want.
Your help will be much appreciated, Happy halloween !