vec_assert: Assert an argument has known prototype and/or size

Description Usage Arguments Value Error types

Description

Usage

1
2
3
4
vec_assert(x, ptype = NULL, size = NULL,
  arg = as_label(substitute(x)))

vec_is(x, ptype = NULL, size = NULL)

Arguments

x

A vector argument to check.

ptype

Prototype to compare against. If the prototype has a class, its vec_ptype() is compared to that of x with identical(). Otherwise, its typeof() is compared to that of x with ==.

size

Size to compare against

arg

Name of argument being checked. This is used in error messages. The label of the expression passed as x is taken as default.

Value

vec_is() returns TRUE or FALSE. vec_assert() either throws a typed error (see section on error types) or returns x, invisibly.

Error types

Both errors inherit from "vctrs_error_assert".


vctrs documentation built on July 6, 2019, 1:03 a.m.