Learn R Programming

structenforcement (version 0.1.3)

type_check: List Type Checking

Description

Given two named objects, go through both and make the types of the second match the types of the first.

Usage

type_check(
  template,
  target,
  with_cast = FALSE,
  log_items = c("casts", "missing", "excess", "debug")[c(1, 3)]
)

Value

The target object, with its types appropriately cast.

Arguments

template
  • A named list to use as a template.

target
  • A named list to use as the output.

with_cast
  • If true, edits the target instead of just checking types.

log_items
  • Which debug info to print. Takes a character vector. By default, logs casts and excess fields (target fields not in template). We expect some missing for the moment.

Examples

Run this code
type_check(
  list("a" = character(0), "b" = integer(0)),
  data.frame("a" = c(1,2), "b" = c(3,4)),
  TRUE, NULL
)

Run the code above in your browser using DataLab