Let\'s say our initial data frame looks like this:
df1 = data.frame(Index=c(1:6),A=c(1:6),B=c(1,2,3,NA,NA,NA),C=c(1,2,3,NA,NA,NA)) > df1 Index A B C
Not sure what the general case or conditions would be, but this works for this instance without dplyr
dplyr
df3 <- as.matrix(df1) df3[which(is.na(df3))] <- as.matrix(df2) df3 <- as.data.frame(df3) df3 A B C 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 5 5 5 4 5 6 6 4 5