missingValueFunctions: Missing-value helper functions.

missingValueFunctionsR Documentation

Missing-value helper functions.

Description

Functions to make code a little clearer. These are mainly ordinary functions, like mean(), with na.rm set to TRUE. For example, meanNA() is defined as function(x) mean(x, na.rm = TRUE).

Usage

allNA(x)

lNA(x, verbose = FALSE)

lNAv(x)

maxNA(x)

meanNA(x)

medianNA(x)

minNA(x)

rangeNA(x)

sdNA(x)

sumNA(x)

varNA(x)

Arguments

x

An R object.

verbose

Logical variable. If TRUE, lNA will print the lengths of x before and after NA values have been removed.

Details

lNA(x) returns its value silently. lNAv is shorthand for lNA(x, verbose = TRUE); it returns the same value as lNA(x) but also prints the lengths of the vector before and after NAs are removed.

Examples

lNA(NA)    # 0

x <- c(1:3, NA, 5)
allNA(x <= 5)  # TRUE
lNA(x)         # 4
lNAv(x)        # 4 (length with NA=5)

sum(NA)        # NA
sumNA(NA)      # 0

sum(x)         # NA
sumNA(x)       # 11
meanNA(x)      # 2.75

sdNA(x)
varNA(x)

jbullock35/Bullock documentation built on April 1, 2022, 6:21 p.m.