R: Default cast method

vec_default_cast {vctrs} | R Documentation

## Default cast method

### Description

This function should typically be called from the default `vec_cast()` method for your class, e.g. `vec_cast.myclass.default()`. It does two things:

- If `x` is an unspecified vector, it automatically casts it to `to` using `vec_init()`.

- Otherwise, an error is thrown with `stop_incompatible_cast()`.

### Usage

    vec_default_cast(x, to, x_arg = "x", to_arg = "to")

### Arguments

`x` | Vectors to cast.
`to` | Type to cast to. If `NULL`, `x` will be returned as is.
`x_arg` | Argument names for `x` and `to`. These are used in error messages to inform the user about the locations of incompatible types (see `stop_incompatible_type()`).
`to_arg` | Argument names for `x` and `to`. These are used in error messages to inform the user about the locations of incompatible types (see `stop_incompatible_type()`).

[Package vctrs version 0.2.2 Index]