Learn R Programming

yamlet (version 1.2.1)

classified.default: Create Classified by Default

Description

Creates a factor of subclass 'classified', for which there are attribute-preserving methods. In particular, classified has a codelist attribute indicating the origin of its levels: it is constructed from the codelist attribute of x if available, or from 'levels' and 'labels' by default. Unlike the case for factor, length of labels cannot be one (i.e., different from length of levels).

Usage

# S3 method for default
classified(
  x = character(),
  levels,
  labels,
  exclude = NA,
  ordered = is.ordered(x),
  nmax = NA,
  token = character(0),
  ...
)

Value

'classified' 'factor'

Arguments

x

see factor

levels

see factor

labels

see factor, must have same length as levels

exclude

see factor

ordered

see factor

nmax

see factor

token

informative label for messages

...

ignored

See Also

Other classified: [.classified(), [<-.classified(), [[.classified(), [[<-.classified(), as.integer.classified(), c.classified(), classified(), classified.classified(), classified.data.frame(), classified.dvec(), classified.factor(), desolve.classified(), unclassified(), unclassified.classified(), unclassified.data.frame()

Examples

Run this code

# classified creates a factor with a corresponding codelist attribute
classified(c('a','b','c'))

# codelist 'remembers' the origins of levels
classified(c('a','b','c'), labels = c('A','B','C'))

# classified is 'reversible'
library(magrittr)
c('a','b','c') %>%
  classified(labels = c('A','B','C')) %>%
  unclassified

Run the code above in your browser using DataLab