classified.default: Create Classified by Default

View source: R/classified.R

classified.defaultR Documentation

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

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

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

Value

'classified' 'factor'

See Also

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

Examples


# 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

bergsmat/yamlet documentation built on Feb. 18, 2024, 5:50 a.m.