Learn R Programming

cheapr (version 1.4.0)

cast: Fast casting/coercing of R objects

Description

cast_common() is type-commutative, meaning the order of objects doesn't affect the outcome type. cast() will attempt to cast x into an object similar to archetype.

Usage

cast(x, archetype)

cast_common(..., .args = NULL)

archetype(x)

archetype_common(..., .args = NULL)

r_type(x)

r_type_common(..., .args = NULL)

Value

cast() will attempt to cast x into an object similar to archetype.

cast_common() coerces all supplied vectors into a common type between them.

archetype() returns the zero-length template/archetype of x.

archetype_common() returns the common zero-length template between all supplied vectors.

r_type() will return the internal cheapr-defined type of x as a character vector of length 1. This will usually match class(x)

but not always.

r_type_common() returns the common type between all objects.

Arguments

x

A vector.

archetype

An archetype vector.

...

Vectors.

.args

An alternative to ... so you can supply arguments directly in a list.
This is equivalent to do.call(f, .args) but much more efficient.