I have two datasets which they have common column names between them, but the values in them are sometimes shared between the datasets. As an example:
df1 <- data.frame(Name = c("Angus", "Angus", "Jason"),
Height=c("1.67", "1.67", "1.89"))
df2 <- data.frame(Name = c("Jack", "Brad", "Jason"),
Weight=c("70", "75", "80"))
And I want to join them into a new data frame so that when there isn't a common value between them such as Angus
in the Name
column, it would be filled with NAs.
My desire example output:
df3 <- data.frame(Name = c("Angus","Angus","Jack", "Brad", "Jason"),
Height=c("1.69", "1.73", "NA","NA","1.89"),
Weight=c("NA","NA","70", "75", "80"))
I am not posting my original dataset because is a big dataset but this simple example perfectly illustrate what I'm desiring.
I allready tried using the merge()
function with fill = NA
but it isn't what I was wanting.