validate_data: Validate tables against the model

View source: R/validate_data.R

validate_dataR Documentation

Validate tables against the model


Validate tables against the model


validate_data(dataset = NULL, path = NULL)



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


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


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


(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.


This function is used by ecocomDP creators (to ensure what has been created is valid), maintainers (to improve the quality of archived ecocomDP datasets), and users (to ensure the data being used is free of error).


## Not run: 
# Write a set of ecocomDP tables to file for validation
mydir <- paste0(tempdir(), "/dataset")
  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)

## End(Not run)

ecocomDP documentation built on June 22, 2024, 6:54 p.m.