Learn R Programming

sicher (version 0.1.0)

create_dataframe_type: Create a Data Frame Type with Column Specification

Description

Builds a type that validates a data frame's column names and their types. Each column is treated as a vector and checked against the provided sicher_type (or union) specification. Optional columns may be declared with `Optional()`.

Usage

create_dataframe_type(col_spec)

Value

A sicher_type representing the data frame schema.

Arguments

col_spec

A named list where names are column names and values are sicher_type or sicher_union objects describing the expected column type.

Examples

Run this code
PersonDF <- create_dataframe_type(list(
  name = String,
  age = Numeric,
  height = Optional(Numeric)
))

df %:% PersonDF %<-% data.frame(
  name = c("Alice", "Bob"),
  age = c(25, 30)
)

Run the code above in your browser using DataLab