categorical: Create a categorical vector

Description Usage Arguments Value Examples

Description

A categorical vector is an extended factor with extra attributes Creating a categorical vector is almost identical to creating a factor.

Usage

1

Arguments

x

vector to be coerced to categorical

cats

optional data.frame with category attributes

levels

optional vector with levels

labels

optional character labels

...

not used

Value

categorical vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gendercats <- data.frame( label = c("male", "female")
                        , code = c("M","F")
                        )


gender <- categorical(c("male", "male", "female", "male"), cats=gendercats)

gender
categories(gender)
relabel(gender, "code")

edwindj/category documentation built on May 15, 2019, 11:04 p.m.