validate_yaml_data: Validate the structure and data types of a data.frame or...

validate_yaml_dataR Documentation

Validate the structure and data types of a data.frame or data.table against specifications defined in a YAML file

Description

!!!STOP!!! This function has been deprecated! Please use tsql_validate_field_types instead.

Validate the structure and data types of a data.frame or data.table against specifications defined in a YAML file. This is most often used to check that your data.frame or data.table is suitable to be pushed to TSQL when a YAML file specifies the field.types to be used by DBI::dbWriteTable & odbc::dbWriteTable.

Usage

validate_yaml_data(ph.data = NULL, YML = NULL, VARS = "vars")

Arguments

ph.data

Name of the data.table/data.frame that you want to assess vis-à-vis the YAML file

YML

Name of the YAML object in memory

VARS

Character vector of length 1. Is is the name of the object in the list contained by YML

Value

A simple printed statement, either identifying incompatible column types or a statement of success

Examples

library(data.table)

# create sample data.table
mydt <- data.table(myalpha = letters[1:10],
                   myint = 1L:10L,
                   mynum = seq(.1, 1, .1))
mydt[, mydate := as.Date('2000-01-01') + myint]
mydt[, myfact := factor(myalpha)]

# create sample yaml object
myyaml <- list(
  myvars = list(
    myalpha = "varchar(255)",
    myint = "int",
    mynum = "float",
    mydate = "date",
    myfact = "varchar(255)"
  )
)

# use function
validate_yaml_data(ph.data = mydt, YML = myyaml, VARS = "myvars")


PHSKC-APDE/rads documentation built on April 14, 2025, 10:47 a.m.