Package 'vek'

Title: Predicate Helper Functions for Testing Simple Atomic Vectors
Description: Predicate helper functions for testing atomic vectors in R. All functions take a single argument 'x' and check whether it's of the target type of base-R atomic vector (i.e. no class extensions nor attributes other than 'names'), returning TRUE or FALSE. Some additionally check for value (e.g. absence of missing values, infinities, blank characters, or 'names' attribute; or having length 1).
Authors: Sam Semegne [aut, cre]
Maintainer: Sam Semegne <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2025-02-17 04:44:42 UTC
Source: https://github.com/samsemegne/vek

Help Index


vek

Description

Predicate helper functions for testing atomic vectors.

All functions take a single argument x and check whether it's of the target type of base-R atomic vector, returning TRUE or FALSE. Some additionally check for value. Classes that extend any base-R atomic vector return FALSE. Vectors that carry any attributes other than 'names' return FALSE.

Function names may include a suffix that encodes what additional conditions are evaluated. A select combination of these conditions is provided for each type. Naming scheme:

  • n: no 'names' attribute

  • x: no NA (type specific)

  • y: no NaN

  • z: no Inf or -Inf

  • b: no blank characters, i.e. ""

  • 1: is of length 1

For example:

  • is_dbl_vec(x) evaluates whether x is a base-R typeof double atomic vector, of any length.

  • is_dbl_vec_xz(x) will additionaly evaluate whether x contains no NA nor Inf values. Note, NaN values are still allowed here, which is dissimilar to behavior from base-R functions like is.na(x) or anyNA(x), wherein both NA and NaN values yield TRUE.

  • is_num_vec_xyz1(x) effectively evaluates whether x is a single real number.

Supported types: logical, integer, double, numeric, and character.

Usage

is_lgl_vec(x)

is_lgl_vec_x(x)

is_lgl_vec_x1(x)

is_lgl_vec_n(x)

is_lgl_vec_nx(x)

is_lgl_vec_nx1(x)

is_int_vec(x)

is_int_vec_x(x)

is_int_vec_x1(x)

is_int_vec_n(x)

is_int_vec_nx(x)

is_int_vec_nx1(x)

is_dbl_vec(x)

is_dbl_vec_x(x)

is_dbl_vec_y(x)

is_dbl_vec_z(x)

is_dbl_vec_xy(x)

is_dbl_vec_yz(x)

is_dbl_vec_xyz(x)

is_dbl_vec_x1(x)

is_dbl_vec_y1(x)

is_dbl_vec_xy1(x)

is_dbl_vec_yz1(x)

is_dbl_vec_xyz1(x)

is_dbl_vec_n(x)

is_dbl_vec_nx(x)

is_dbl_vec_ny(x)

is_dbl_vec_nz(x)

is_dbl_vec_nxy(x)

is_dbl_vec_nyz(x)

is_dbl_vec_nxyz(x)

is_dbl_vec_nx1(x)

is_dbl_vec_ny1(x)

is_dbl_vec_nxy1(x)

is_dbl_vec_nyz1(x)

is_dbl_vec_nxyz1(x)

is_chr_vec(x)

is_chr_vec_x(x)

is_chr_vec_b(x)

is_chr_vec_xb(x)

is_chr_vec_x1(x)

is_chr_vec_b1(x)

is_chr_vec_xb1(x)

is_chr_vec_n(x)

is_chr_vec_nx(x)

is_chr_vec_nb(x)

is_chr_vec_nxb(x)

is_chr_vec_nx1(x)

is_chr_vec_nb1(x)

is_chr_vec_nxb1(x)

is_num_vec(x)

is_num_vec_x(x)

is_num_vec_y(x)

is_num_vec_z(x)

is_num_vec_xy(x)

is_num_vec_yz(x)

is_num_vec_xyz(x)

is_num_vec_x1(x)

is_num_vec_y1(x)

is_num_vec_yz1(x)

is_num_vec_xy1(x)

is_num_vec_xyz1(x)

is_num_vec_n(x)

is_num_vec_nx(x)

is_num_vec_ny(x)

is_num_vec_nz(x)

is_num_vec_nxy(x)

is_num_vec_nyz(x)

is_num_vec_nxyz(x)

is_num_vec_nx1(x)

is_num_vec_ny1(x)

is_num_vec_nyz1(x)

is_num_vec_nxy1(x)

is_num_vec_nxyz1(x)

Arguments

x

any.

Value

logical. Returns TRUE or FALSE.

See Also

vector()