labelled: Create a labelled vector.

Description Usage Arguments See Also Examples

Description

A labelled vector is a common data structure in other statistical environments, allowing you to assign text labels to specific values.

Usage

1
2
3

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.

See Also

labelled (haven)

is.labelled (haven)

Examples

1
2
3
4
5
s1 <- labelled(c('M', 'M', 'F'), c(Male = 'M', Female = 'F'))
s1
s2 <- labelled(c(1, 1, 2), c(Male = 1, Female = 2))
s2
is.labelled(s1)

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