Learn R Programming

misty (version 0.7.1)

na.prop: Proportion of Missing Data for Each Case

Description

This function computes the proportion of missing data for each case in a data frame.

Usage

na.prop(data, ..., digits = 2, append = TRUE, name = "na.prop",
        as.na = NULL, check = TRUE)

Value

Returns a numeric vector with the same length as the number of rows in data

containing the proportion of missing data.

Arguments

data

a data frame with incomplete data, where missing values are coded as NA.

...

an expression indicating the variable names in data, e.g., na.prop(dat, x1, x2, x3). Note that the operators ., +, -, ~, :, ::, and ! can also be used to select variables, see 'Details' in the df.subset function.

name

a character string indicating the name of the variable appended to the data frame specified in the argument data when append = TRUE.

.

append

logical: if TRUE (default), variable with proportion of missing data is appended to the data frame specified in the argument data

digits

an integer value indicating the number of decimal places to be used for displaying proportions.

as.na

a numeric vector indicating user-defined missing values, i.e. these values are converted to NA before conducting the analysis.

check

logical: if TRUE, argument specification is checked.

Author

Takuya Yanagida takuya.yanagida@univie.ac.at

References

Enders, C. K. (2010). Applied missing data analysis. Guilford Press.

Graham, J. W. (2009). Missing data analysis: Making it work in the real world. Annual Review of Psychology, 60, 549-576. https://doi.org/10.1146/annurev.psych.58.110405.085530

van Buuren, S. (2018). Flexible imputation of missing data (2nd ed.). Chapman & Hall.

See Also

as.na, na.as, na.auxiliary, na.coverage, na.descript, na.indicator, na.pattern, na.test

Examples

Run this code
# Example 1: Compute proportion of missing data for each case in the data frame
na.prop(airquality)

# Example 2: Do not append proportions of missing data to the data frame
na.prop(airquality, append = FALSE)

Run the code above in your browser using DataLab