matches_tabde: Check If a Data Frame Matches a Table Design

Description Usage Arguments Details Value Examples

Description

If a columns has the col_type NA in the table_design, it will be checked if the column is present in x, but the column type can be arbitrary.

Usage

1
2
matches_tabde(x, table_design, skip = "#skip", values = NULL,
  check_nulls = FALSE)

Arguments

x

a data.frame

table_design

a table_design

skip

character vector. Columns where the col_type in table_design matches any of the strings in skip will not be checked. see also as_col_spec()

values

a values Object. If x contains a col_domain column, valid values for each domain are looked up in values

check_nulls

logical. If set to TRUE and table_design is a table_design_sql with an "sql_opts" column, this checks if NOT NULL columns contain NA

Details

If used with assertthat, matches_tabde() produces verbose error messages.

Value

logical scalar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
td <- get_tabde(iris)

matches_tabde(iris, td)
matches_tabde(cars, td)

# Nice error messages with assertthat
if (requireNamespace("assertthat", quietly = TRUE)){
  try(assertthat::assert_that(matches_tabde(cars, td)))
}


td <- get_tabde_sql(iris)
td$sql_opts <- "NOT NULL"
x <- iris
x$Species[1] <- NA

matches_tabde(x, td)
matches_tabde(x, td, check_nulls = TRUE)

# Nice error messages with assertthat
if (requireNamespace("assertthat", quietly = TRUE)){
  try(assertthat::assert_that(matches_tabde(x, td, check_nulls = TRUE)))
}

s-fleck/tabde documentation built on May 4, 2019, 1:23 p.m.