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

Include test xmaps and links as internal data? #106

Closed cynthiahqy closed 1 year ago

cynthiahqy commented 1 year ago

currently links and xmaps are defined inside tests. It's not really a problem other than it's a bit repetitive.

An alternative could be to define internal data used by tests and just call that in the tests, but then it's less clear what we are testing -- i.e. you have to examine the internal data object and/or name them really well.

Could look something like:

Internal xmap test objects

narrow_df <- tibble::tribble(
      ~f, ~t, ~w,
          "a",  "AA",     1,
          "b",  "AA",     1,
          "c",  "AA",     1,
          "d",  "BB",     1,
          "e",  "CC",     1,
          "f",  "DD",   0.3,
          "f",  "EE",   0.3,
          "f",  "FF",   0.4
      )

wide_df <- narrow_df |> dplyr::mutate(extra = "extra info")

int_dat$narrow_xmap <- new_xmap_df(narrow_df, "f", "t", "w")
int_dat$wide_xmap <- new_xmap_df(wide_df, "f", "t", "w")

usethis::use_data(int_dat, internal = TRUE, overwrite = TRUE)
cynthiahqy commented 1 year ago

Probably not necessary for now unless issues arise with how long the tests take to run...