vctrs (version 0.0.0.9000)

vec_coerce: Coerce vectors to common type

Description

This function is primarily useful as a building block for other functions. The implementation also illustrates the key ideas of the vctrs type system, and allows you to experiment interactively.

Usage

vec_coerce(..., .ptype = NULL)

Arguments

...

Vectors to coerce.

.ptype

If NULL, the default, the output type is determined by computing the common type across all elements of ....

Alternatively, you can supply .ptype to give the output known type. If getOption("vctrs.no_guessing") is TRUE you must supply this value: this is a convenient way to make production code demand fixed types.

Value

A list_of input vectors coerced to .ptype, an error stating that a common type could not be found, or an error stating that casting a input to .ptype was not possible.

Examples

Run this code
# NOT RUN {
vec_coerce(factor("a"), factor(c("a", "b")))
vec_coerce(factor("a"), Sys.Date(), .ptype = list())
# }

Run the code above in your browser using DataLab