freeze_na_proportion: Adjust target proportions to add a category for missing data

View source: R/augment_nas.R

freeze_na_proportionR Documentation

Adjust target proportions to add a category for missing data

Description

This function adds an additional level to any target variable to represent missing data. The proportion given to the missing data is the proportion missing in the observed sample. Other proportions are adjusted accordingly. This is a private function and not intended for end-user use.

Usage

freeze_na_proportion(data, target, which_vars)

Arguments

data

A data frame (tibble) or matrix containing sample data, specified as in harvest

target

A list of named vectors, specified as in harvest

which_vars

A boolean, numeric, or character vector specifying which variables to adjust in this manner. If boolean, all variables are selected. If character, those named variables are selected. If numeric, variables are selected based on numeric position amongst the target variables.

Value

An augmented target list, where affected variables with observed missing data in the sample has an additional level named "___NA" reflecting the proportion of data missing in the sample and other levels are adjusted accordingly


aaronrudkin/autumn documentation built on Feb. 5, 2024, 6:08 p.m.