validateDataPackage() checks whether an MR1 data package,
created by createDataPackage(), is complete and consistent before it is
published, e.g. on Zenodo. It checks:
the package structure (Frictionless Data Package) and the package-level metadata (the same checks as in
createDataPackage(), plus the properties thatcreateDataPackage()adds automatically);that all five resources (
echo_data,protocol_data,blind_times,sunrise_sunset,site_data) are present, can be read, and contain the required columns;that the column names and types match the Table Schema of each resource, and that every column has a description;
that primary keys are unique and not missing, and that foreign keys (e.g.
protocolIDof the echoes) refer to existing rows;that the content is plausible: start times before stop times, echoes within their measurement period and within the temporal coverage, and site coordinates equal to the spatial coverage.
Problems that make the package unusable or inconsistent are reported as errors; problems that do not, e.g. a column without description, as warnings. A package is valid when there are no errors.
Arguments
- package
MR1 data package object returned by
createDataPackage()orfrictionless::read_package(), or the path to adatapackage.jsonfile or to the directory that contains it.
Value
An object of class mr1dpValidation: a list with valid (logical,
TRUE if no errors were found) and issues (data frame with the columns
level ("error" or "warning"), resource, field and message).
Printing it gives a summary of the issues.
See also
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo()
Examples
# \donttest{
# Load example data
# ===========================================================================
dbData = readRDS(system.file("extdata",
"CH_Sempach_2024_SEP24_25_DataExtract.rds",
package = "birdscanR"
))
mainOutputDir = tempdir()
# Write the package metadata template (fill it in for a real campaign)
# ===========================================================================
metadataFile = file.path(mainOutputDir, "CH_Sempach_2024_metadata.yaml")
createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE)
# Create MR1 data package
# ===========================================================================
dataPackage = createDataPackage(
dbExtract = dbData,
metadata = metadataFile,
pulseTypeSelection = "S",
outputDirPath = mainOutputDir
)
# Validate the data package object
# ===========================================================================
validateDataPackage(dataPackage)
#> The MR1 data package is valid.
# Validate the data package files on disk
# ===========================================================================
validation = validateDataPackage(file.path(mainOutputDir, "CH_Sempach_2024"))
validation$valid
#> [1] TRUE
# }