Learn R Programming

VIM (version 6.2.2)

gapMiss: Missing value gap statistics

Description

Computes the average missing value gap of a vector.

Usage

gapMiss(x, what = mean)

Value

The gap statistics

Arguments

x

a numeric vector

what

default is the arithmetic mean. One can include an own function that returns a vector of lenght 1 (e.g. median)

Author

Matthias Templ based on a suggestion and draft from Huang Tian Yuan.

Details

The length of each sequence of missing values (gap) in a vector is calculated and the mean gap is reported

Examples

Run this code
v <- rnorm(20)
v[3] <- NA
v[6:9] <- NA
v[13:17] <- NA
v
gapMiss(v)
gapMiss(v, what = median)
gapMiss(v, what = function(x) mean(x, trim = 0.1))
gapMiss(v, what = var)

Run the code above in your browser using DataLab