xcast: Cast New Values for 'xnew_data()'

View source: R/xcast.R

xcastR Documentation

Cast New Values for xnew_data()

Description

Casts a sequence of values to the same class as the original vector.

Usage

xcast(..., .data = xnew_data_env$data)

Arguments

...

TBD

.data

Normally defined by xnew_data(), users must pass a data frame or tibble if using this function directly.

Details

xnew_seq() is a wrapper function on vctrs::vec_cast() for use in xnew_data() to avoid having to repeating the column name.

See Also

vctrs::vec_cast() and xnew_data()

Examples

data <- tibble::tibble(
  period = factor(c("before", "before", "after", "after"),
    levels = c("before", "after")),
  annual = factor(c(1, 3, 5, 8), levels = c(1, 3, 5, 8)))

xnew_data(data, xcast(period = "before"))
xnew_data(data, xcast(period = "before", annual = c("1", "3")))

poissonconsulting/newdata documentation built on Jan. 18, 2024, 1:30 a.m.