fill_missing_l2 | R Documentation |
For cases where you have a long format data set and it contains level 2 data but some of the level 2 data are missing although the necessary information in available in other data rows of the same grouping value.
fill_missing_l2(data, id, vars)
data |
A data frame |
id |
Character string with L2 variable |
vars |
Vector of strings with variable names |
A data frame with added values. It also reports if l2 values conflict.
x <- data.frame(
id = rep(1:5, each = 3),
gender = c(1, 1, NA, 0, 0, 0, 1, NA, NA, NA, NA, NA, 1, 0, NA)
)
x
fill_missing_l2(x, "id", "gender")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.