na.pattern: Missing Data Pattern

View source: R/na.pattern.R

na.patternR Documentation

Missing Data Pattern

Description

This function computes a summary of missing data patterns, i.e., number ( cases with a specific missing data pattern.

Usage

na.pattern(x, order = FALSE, digits = 2, as.na = NULL, write = NULL,
           check = TRUE, output = TRUE)

Arguments

x

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

order

logical: if TRUE, variables are ordered from left to right in increasing order of missing values.

digits

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

as.na

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

write

a character string for writing the results into a Excel file naming a file with or without file extension '.xlsx', e.g., "Results.xlsx" or "Results".

check

logical: if TRUE, argument specification is checked.

output

logical: if TRUE, output is shown.

Value

Returns an object of class misty.object, which is a list with following entries:

call

function call

type

type of analysis

data

matrix or data frame specified in x

args

specification of function arguments

result

result tables

pattern

group variable of missing data pattern

Author(s)

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

write.result, as.na, na.as, na.auxiliary, na.coverage, na.descript, na.indicator, na.prop, na.test

Examples

dat <- data.frame(x = c(1, NA, NA, 6, 3),
                  y = c(7, NA, 8, 9, NA),
                  z = c(2, NA, 3, NA, 5))

# Compute a summary of missing data patterns
dat.pattern <- na.pattern(dat)

# Vector of missing data pattern for each case
dat.pattern$pattern
# Data frame without cases with missing data pattern 2 and 5
dat[!dat.pattern$pattern %in% c(2, 5), ]

## Not run: 
# Write Results into a Excel file
result <- na.pattern(dat, write = "NA_Pattern.xlsx")

result <- na.pattern(dat, output = FALSE)
write.result(result, "NA_Pattern.xlsx")

## End(Not run)

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to na.pattern in misty...