validate_yaml_data | R Documentation |
!!!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
.
validate_yaml_data(ph.data = NULL, YML = NULL, VARS = "vars")
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 |
A simple printed statement, either identifying incompatible column types or a statement of success
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.