R: Convert to a base subscript type

vec_as_subscript {vctrs} | R Documentation

## Convert to a base subscript type

### Description

Convert `i` to the base type expected by `vec_as_location()` or `vec_as_location2()`. The values of the subscript type are not checked in any way (length, missingness, negative elements).

### Usage

    vec_as_subscript(
      i,
      ...,
      logical = c("cast", "error"),
      numeric = c("cast", "error"),
      character = c("cast", "error"),
      arg = NULL
    )

    vec_as_subscript2(
      i,
      ...,
      logical = c("cast", "error"),
      numeric = c("cast", "error"),
      character = c("cast", "error"),
      arg = NULL
    )

### Arguments

`i` | An integer, character or logical vector specifying the locations or names of the observations to get/set. Specify `TRUE` to index all elements (as in `x[]`), or `NULL`, `FALSE` or `integer()` to index none (as in `x[NULL]`).
`...` | These dots are for future extensions and must be empty.
`logical, location, character` | How to handle logical, numeric, and character subscripts. If `"cast"` and the subscript is not one of the three base types (logical, integer or character), the subscript is cast to the relevant base type, e.g. factors are coerced to character. `NULL` is treated as an empty integer vector, and is thus coercible depending on the setting of `numeric`. Symbols are treated as character vectors and thus coercible depending on the setting of `character`. If `"error"`, the subscript type is disallowed and triggers an informative error.
`arg` | The argument name to be displayed in error messages when `vec_as_location()` and `vec_as_location2()` are used to check the type of a function input.

[Package vctrs version 0.3.2 Index]