total <- merge(MEX,US,by=c("Country_Of_Data","Year"))
US DATA
## Country_Of_Data Year US
## <chr> <dbl> <dbl>
## 1 Angola 2010 0
## 2 Angola 2011 1
## 3 Angola 2012 3
## 4 Angola 2013 1
## 5 Angola 2014 0
## 6 Angola 2015 1
## 7 Angola 2016 1
## 8 Angola 2017 0
## 9 Angola 2018 0
MEX DATA
## Country_Of_Data Year MEX
## <chr> <dbl> <dbl>
## 1 Angola 2014 1
## 2 Angola 2015 3
## 3 Angola 2016 55
## 4 Angola 2017 96
## 5 Angola 2018 151
## 6 Angola 2019 857
## Country_Of_Data Year US MEX
## 1 Angola 2014 0 1
## 2 Angola 2015 1 3
## 3 Angola 2016 1 55
## 4 Angola 2017 0 96
## 5 Angola 2018 0 151
When I am rbinding the two datasets I seem to lose values since the years aren't associated in one of the datasets, in this case: MEX. I wanted to know if there is a way that could keep the years even if it isn't in one of the datasets and just make the value 0 or NA in the other set.