labelled_spss: Create a labelled vector with SPSS style of missing values.

Description Usage Arguments See Also Examples

Description

It is similar to the labelled class but it also models SPSS's user-defined missings, which can be up to three distinct values, or for numeric vectors a range.

Usage

1

Arguments

x

A vector to label. Must be either numeric (integer or double) or character.

labels

A named vector. The vector should be the same type as x. Unlike factors, labels don't need to be exhaustive: only a fraction of the values might be labelled.

na_values

A vector of values that should also be considered as missing.

na_range

A numeric vector of length two giving the (inclusive) extents of the range. Use -Inf and Inf if you want the range to be open ended.

See Also

labelled_spss (haven)

Examples

1
2
3
4
5
6
x1 <- labelled_spss(1:10, c(Good = 1, Bad = 8), na_values = c(9, 10))
x1
is.na(x1)
x2 <- labelled_spss(1:10, c(Good = 1, Bad = 8), na_range = c(9, Inf))
x2
is.na(x2)

labelled documentation built on May 25, 2018, 1:03 a.m.