cynthiahqy / conformr-xmap-project

R Package for harmonising data of different classifications or aggregations into a single dataset
MIT License
7 stars 1 forks source link

Add validate_as_xmap() helper which wraps internal validate_xmap() #82

Closed cynthiahqy closed 1 year ago

cynthiahqy commented 1 year ago

TODO

To simplify error handling,

It doesn't really make sense to have xmap_validate() functions since the xmap have to be validated before becoming an xmap; and if you made it some other way, then it still makes sense that you want to validate_as_xmap(). The most likely workflow is:

links |>
  validate_as_xmap()

not

links |>
  as_xmap() |>
  xmap_validate()

It could make sense though to have validation for special types #88 e.g.:

xmap |>
  xmap_validate_as_recode()

with additional types:

cynthiahqy commented 1 year ago

Generic: validate_as_xmap()

#' Validation Helper for `xmap` objects
#'
#' @param x A candidate object (i.e. data frame) to be validated
#'
#' @return `x` if validation passes. Throws error otherwise.
#'
#' @section Methods:
#' \Sexpr[stage=render,results=rd]{generics:::methods_rd("xmap_validate")}
#'
#' @export
#'
validate_as_xmap <- function(x) {
  UseMethod("validate_as_xmap")
}
cynthiahqy commented 1 year ago

This would allow the crossmap approach to be integrated into existing data preprocessing pipelines

cynthiahqy commented 1 year ago