Learn R Programming

ecocomDP (version 1.3.2)

validate_data: Validate tables against the model

Description

Validate tables against the model

Usage

validate_data(dataset = NULL, path = NULL)

Value

(list) If any checks fail, then a list of validation issues are returned along with a warning. If no issues are found then NULL is returned.

Arguments

dataset

(list) A dataset of the structure returned by read_data().

path

(character) Path to a directory containing ecocomDP tables as files.

Details

Validation checks:

  • File names - File names are the ecocomDP table names.

  • Table presence - Required tables are present.

  • Column names - Column names of all tables match the model.

  • Column presence - Required columns are present.

  • Column classes - Column classes match the model specification.

  • Datetime format - Date and time formats follow the model specification.

  • Primary keys - Primary keys of tables are unique.

  • Composite keys - Composite keys (unique constraints) of each table are unique.

  • Referential integrity - Foreign keys have a corresponding primary key.

  • Coordinate format - Values are in decimal degree format.

  • Coordinate range - Values are within -90 to 90 and -180 to 180.

  • Elevation - Values are less than Mount Everest (8848 m) and greater than Mariana Trench (-10984 m).

  • Variable mapping - variable_name is in table_name.

  • Mapped_id - values in mapped_id are valid URIs

Examples

Run this code
if (FALSE) {
# Write a set of ecocomDP tables to file for validation
mydir <- paste0(tempdir(), "/dataset")
dir.create(mydir)
write_tables(
  path = mydir,
  observation = ants_L1$tables$observation, 
  observation_ancillary = ants_L1$tables$observation_ancillary,
  location = ants_L1$tables$location,
  location_ancillary = ants_L1$tables$location_ancillary,
  taxon = ants_L1$tables$taxon,
  taxon_ancillary = ants_L1$tables$taxon_ancillary,
  dataset_summary = ants_L1$tables$dataset_summary,
  variable_mapping = ants_L1$tables$variable_mapping)

# Validate
validate_data(path = mydir)

# Clean up
unlink(mydir, recursive = TRUE)
}

Run the code above in your browser using DataLab