Learn R Programming

mark (version 0.8.2)

fct_expand_seq: Factor Expand by Sequence

Description

Expands an ordered factor from one level to another

Usage

fct_expand_seq(
  x,
  min_lvl = min(x, na.rm = TRUE),
  max_lvl = max(x, na.rm = TRUE),
  by = 1L
)

Value

An ordered vector

Arguments

x

An ordered factor

min_lvl

The start of the level sequence

max_lvl

The end of the level sequence

by

Integer, number of steps in between

Details

Defaults for min_lvl and max_lvl are the minimum and maximum levels in the ordered vector x.

Examples

Run this code
x <- ordered(letters[c(5:15, 2)], levels = letters)
fct_expand_seq(x)
fct_expand_seq(x, "g", "s", 3L) # from "g" to "s" by 3
fct_expand_seq(x, "g", "t", 3L) # same as above

# from the first inherit level to the last observed
fct_expand_seq(x, min(levels(x)))

Run the code above in your browser using DataLab