powered by
Coerce the input to a different class, with a warning. More reliable then as, and supports coercion to multiple classes.
as
coerce_to(x, target_class, .xname = get_name_in_parent(x))
Input to coerce.
The desired class of x. Multiple values allowed (see note).
Not intended to be used directly.
The input x after attempted coercion to the target class.
x
is and as.
is
# NOT RUN { # Numbers can be coerced to characters but not to calls. dont_stop(coerce_to(1:5, c("call", "character"))) # }
Run the code above in your browser using DataLab