I have two datasets originally from the same source, but due to categorization I found it necessary to divide these. I was wondering how to merge these datasets back based on missing values from two columns? In other words, I need all the rows (columns are identical as they are from the same source) from dataset 1 and then based on a columns indicating years and country code when rows are missing from dataset 1 extract the rows from dataset 2?
df1 <- read.table(
text =
"Year, Data,Country
1,2,US
3,2,US
5,1,US
1,3,UK
2,5,UK
4,3,UK
", sep = ",", header = TRUE)
df1
df2 <- read.table(
text =
"Year, Data,Country
1,3,US
4,5,US
5,8,US
2,9,UK
3,4,UK
", sep = ",", header = TRUE)
df2
df3 <- read.table(
text =
"Year, Data,Country
1,2,US
3,2,US
4,5,US
5,1,US
1,3,UK
2,5,UK
3,4,UK
4,3,UK
", sep = ",", header = TRUE)
df3
The df3 extracts the missing year values from df1 and df2. How would this extraction be coded?
rstudiotag unless your question is directly related to the Rstudio IDE - Mr.Rlover