Learn R Programming

rray (version 0.0.0.9000)

vec_type_inner: Find the inner type of a set of vectors

Description

vec_type_inner() finds the inner type of a single vector. vec_type_inner_common() finds the common inner type of multiple vectors.

Usage

vec_type_inner(x)

vec_type_inner_common(..., .ptype = NULL)

Arguments

x

A vector.

...

Vectors to determine the common inner type of.

.ptype

If not NULL, this overrides the common inner type of ....

Details

The inner type is a 0-size, 0-shape prototype that represents the "inner" type of x. The return value is essentially the object form of typeof().

For complex types, a method should be written that returns an empty inner type of that input with no shape or size. If that complex type can have multiple inner types, the method should be written so that it returns the correct inner type of the current input. The return value should not have the class of the classed input.

The common inner type is useful alongside vec_cast_inner(). For example, rray_bind() uses vec_type_inner_common() to determine the common inner type, and then uses vec_cast_inner() to cast each of the inputs to the same inner type before binding them together.

Examples

Run this code
# NOT RUN {
# The inner type of base R atomics uses their constructor
# vec_type_inner(1)

# The inner type of an rray is an empty base R object
# vec_type_inner(rray(1))

# Find the common inner type of multiple inputs
# (the double type wins, the container types are disregarded)
# vec_type_inner_common(1, TRUE, rray(1L))

# }

Run the code above in your browser using DataLab