Impute zero for NA values in financial fields, respecting form scope
Source:R/utils.R
impute_zero.RdFor a given set of column names and a data frame, imputes zero for NA values in financial fields while respecting whether a field is available to 990-EZ filers. PC-scope fields (990 only) are imputed only for rows that are not 990-EZ filers. PZ-scope fields (990 + 990-EZ) are imputed for all rows. Rows where every financial variable is NA are left untouched.
Arguments
- dat
A
data.frame(the working subset, not the full dataset).- vars
Character vector of financial column names to consider.
- ez_rows
Logical vector (length
nrow(dat)) marking 990-EZ rows, as returned bydetect_ez_rows().
Examples
data( dat10k )
ez <- detect_ez_rows( dat10k )
dat_imp <- impute_zero( dat10k, vars = get_pc_fields(), ez_rows = ez )