fillin
replaces missing values with existing observations from other variable or data frame.fillin
replaces missing values with existing observations from other variable or data frame.fillin(x, y, x.var, y.var = NULL, key)
x
.x
you want to fill in.y
that you would like to use to fill in.x
and y
that can be used to join the data frames.# 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