fill_missing_l2: Fills in missing level 2 data

View source: R/fill_l2_data.R

fill_missing_l2R Documentation

Fills in missing level 2 data

Description

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.

Usage

fill_missing_l2(data, id, vars)

Arguments

data

A data frame

id

Character string with L2 variable

vars

Vector of strings with variable names

Value

A data frame with added values. It also reports if l2 values conflict.

Examples

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")

jazznbass/wmisc documentation built on Oct. 29, 2024, 5:42 p.m.