Skip to content

vec_ptype2() defines the coercion hierarchy for a set of related vector types. Along with vec_cast(), this generic forms the foundation of type coercions in vctrs.

vec_ptype2() is relevant when you are implementing vctrs methods for your class, but it should not usually be called directly. If you need to find the common type of a set of inputs, call vec_ptype_common() instead. This function supports multiple inputs and finalises the common type.

Usage

# S3 method for logical
vec_ptype2(x, y, ..., x_arg = "", y_arg = "")

# S3 method for integer
vec_ptype2(x, y, ..., x_arg = "", y_arg = "")

# S3 method for double
vec_ptype2(x, y, ..., x_arg = "", y_arg = "")

# S3 method for complex
vec_ptype2(x, y, ..., x_arg = "", y_arg = "")

# S3 method for character
vec_ptype2(x, y, ..., x_arg = "", y_arg = "")

# S3 method for raw
vec_ptype2(x, y, ..., x_arg = "", y_arg = "")

# S3 method for list
vec_ptype2(x, y, ..., x_arg = "", y_arg = "")

vec_ptype2(
  x,
  y,
  ...,
  x_arg = caller_arg(x),
  y_arg = caller_arg(y),
  call = caller_env()
)

Arguments

x, y

Vector types.

...

These dots are for future extensions and must be empty.

x_arg, y_arg

Argument names for x and y. These are used in error messages to inform the user about the locations of incompatible types (see stop_incompatible_type()).

call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

Implementing coercion methods

Dependencies

See also

stop_incompatible_type() when you determine from the attributes that an input can't be cast to the target type.