new_factor

0th

Percentile

Factor/ordered factor S3 class

A factor is an integer with attribute levels, a character vector. There should be one level for each integer between 1 and max(x). An ordered factor has the same properties as a factor, but possesses an extra class that marks levels as having a total ordering.

Keywords
internal
Usage
new_factor(x = integer(), levels = character(), ...,
  class = character())

new_ordered(x = integer(), levels = character())

# S3 method for factor vec_type2(x, y)

# S3 method for ordered vec_type2(x, y)

# S3 method for factor vec_cast(x, to)

Arguments
x

Integer values which index in to levels.

levels

Character vector of labels.

..., class

Used to for subclasses.

Details

These functions help the base factor and ordered factor classes fit in to the vctrs type system by providing constructors, coercion functions, and casting functions. new_factor() and new_ordered() are low-level constructors - they only check that types, but not values, are valid, so are for expert use only.

Aliases
  • new_factor
  • new_ordered
  • vec_type2.factor
  • vec_type2.ordered
  • vec_cast.factor
Documentation reproduced from package vctrs, version 0.1.0, License: GPL-3

Community examples

Looks like there are no examples yet.