Skip to content

Add check_cols() function to error on missing columns #540

Description

@peterdesmet

It is possible to provide any package to write_dwc(). That package might be missing required resources (already covered) or fields that are used in the mapping. For example, the 2014_demer dataset currently deposited on MDA does not have tag_serial_number in animals. The user currently gets a deep dplyr error for this. It might be useful to provide an error earlier.

I suggest a generic check_cols() function (name similar to expand_cols()), called from within create_animal_occurrences() and create_gps_occurrences():

required_cols <- c("animal_id", "tag_serial_number")
check_cols(animals, required_cols)

It would return TRUE if all is fine, but return a nice error if one of the provided columns is not present. See https://github.com/inbo/movepub/blob/7c20e5aabfa2213a6605e35ffd4fed6d6664e4e5/R/check_ref.R#L16-L24 for inspiration on the error message.


  • The function can later be called from create_ano() too.
  • The required_cols could be maintained in each function and test or be stored as globals.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions