Skip to contents

createDataPackageMetadataTemplate() writes a commented YAML template with the package-level metadata of an MR1 data package: campaign ID, title, description, version, owner, licence, embargo, keywords, contributors (with ORCID, affiliation, DataCite roles and embargo request type), related identifiers and suggested citation. Fill in the template and pass its path to the metadata argument of createDataPackage(), and check it first with checkDataPackageMetadata(). To fill in the metadata in a form instead of a text editor, use editDataPackageMetadata().

Without dbExtract, the template contains example values for the Sempach test dataset. With dbExtract, the values that can be derived from the data are filled in: campaign ID (<countryCode>_<site name>_<year(s)>), title and description (site name and the period of the echo data) and owner (the customer of the site). The example contributor is removed, so the contributors must be filled in before the metadata pass the checks.

Usage

createDataPackageMetadataTemplate(
  filePath,
  dbExtract = NULL,
  countryCode = NULL,
  overwrite = FALSE
)

Arguments

filePath

Path of the YAML file to write.

dbExtract

optional. Named list with the database tables extracted by extractDbData() (at least siteData and echoData), used to fill in the template.

countryCode

optional. Two-letter ISO country code of the site (e.g. "CH"), used for the campaign ID. Without it, the campaign ID is left empty (with a suggestion in a comment).

overwrite

logical. If TRUE, an existing file is overwritten. Default is FALSE.

Value

The path of the written file, invisibly.

Author

Birgen Haest

Examples

# Write the metadata template
# ===========================================================================
metadataFile = file.path(tempdir(), "CH_Sempach_2024_metadata.yaml")
createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE)

# Write a template filled in from the data
# ===========================================================================
dbData = readRDS(system.file("extdata",
  "CH_Sempach_2024_SEP24_25_DataExtract.rds",
  package = "birdscanR"
))
createDataPackageMetadataTemplate(
  filePath    = metadataFile,
  dbExtract   = dbData,
  countryCode = "CH",
  overwrite   = TRUE
)
#> Fill in the contributors in /tmp/RtmpwbGa0R/CH_Sempach_2024_metadata.yaml and check the other values.
# Fill in the contributors, then check the file
checkDataPackageMetadata(metadataFile)
#> The data package metadata are not valid:
#> - 'contributors' is required and must contain at least one contributor.