0

I have two excel tables open in rstudio. I want to combine them so that the rows missing Date of Birth in the first table are filled with the Date of Birth values in the second table. To put it in mathematical terms, I want this:

If table1.id = table2.id Then table1.dob = table2.dob

Is there a way to run such a code?

Jaap
  • 81,064
  • 34
  • 182
  • 193
canigan
  • 29
  • 6

1 Answers1

1

Your example did not provide a reproducible example. You should take a look here

To your purpose take a look on merge command

merged_df <- merge(df1, df2, by = "my_id_variable")

Let's generete same toy data and merging:

# Toy data 
x <- data.frame(id = paste("ID", (1:5), sep = ""), v1 = c(1:5)) 
y <- data.frame(id = paste("ID", (1:5), sep = ""), v2 = c(6:10))

xy <- merge(x, y, by = "id")
Borexino
  • 802
  • 8
  • 26