validate_types: Type check variables

View source: R/validate_types.R

validate_typesR Documentation

Type check variables

Description

This function checks the type of variables in a safeframe against accepted classes. Only checks the type of provided variables and ignores those not provided.

Usage

validate_types(x, ...)

Arguments

x

a safeframe object

...

<dynamic-dots> A named list with tags in x as list names and the related types as list values.

Value

A named list.

See Also

  • validate_tags() to perform a series of checks on variables

  • validate_safeframe() to combine validate_tags and validate_types

Examples

x <- make_safeframe(cars,
  mph = "speed",
  distance = "dist"
)
x

## the below would issue an error
## note: tryCatch is only used to avoid a genuine error in the example
tryCatch(validate_types(x), error = paste)

## to allow other types, e.g. gender to be integer, character or factor
validate_types(x, mph = "numeric", distance = c(
  "integer",
  "character", "numeric"
))


safeframe documentation built on June 28, 2025, 1:08 a.m.