# Create data set with missing values
data1 <- data.frame(a = sample(c(1,2), 100, rep=TRUE),
b = sample(c(3,4), 100, rep=TRUE),
fNA = sample(c(100, 200, 300, 400, NA), 100, rep=TRUE))
# Created full data set
data2 <- data.frame(a = c(1,2,1,2),
b = c(3,3,4,4),
full = c(100, 200, 300, 400))
# Fill in missings from data1 with values from data2
Filled <- fillin(data1, data2, x.var = "fNA", y.var = "full", key = c("a", "b"))
Run the code above in your browser using DataLab