Casts a sequence of values to the same class as the original vector.
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.
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"))
#> # A tibble: 1 × 2
#> period annual
#> <fct> <fct>
#> 1 before 1
xnew_data(data, xcast(period = "before", annual = c("1", "3")))
#> # A tibble: 2 × 2
#> period annual
#> <fct> <fct>
#> 1 before 1
#> 2 before 3