pharmaverse / admiralophtha

Ophthalmology package extension of admiral
https://pharmaverse.github.io/admiralophtha
Apache License 2.0
15 stars 3 forks source link

Bug: `derive_var_afeye()` throws erroneous warnings when `xxLOC` or `xxLAT` are missing #214

Closed manciniedoardo closed 12 months ago

manciniedoardo commented 1 year ago

What happened?

See reproducible example. This is happening because these checks

if (!all(unique(dataset_occ[[lat_var]]) %in% lat_vals)) {
     warning("Warning: value not in lat_vals")
   }
   if (!all(unique(dataset_occ[[loc_var]]) %in% loc_vals)) {
     warning("Warning: value not in loc_vals")
   }
   if (!all(unique(dataset_occ$STUDYEYE) %in% seye_vals)) {
     warning("Warning: STUDYEYE is expected to be 'LEFT', 'RIGHT' or 'BILATERAL'")

should have been removed and were not.

Function could also be enhanced such that user can pass in seye_vals as well.

Session Information

No response

Reproducible Example

adae <- tribble(
  ~STUDYID, ~USUBJID, ~STUDYEYE, ~AELOC, ~AELAT,
  "XXX001", "P01", "RIGHT", "EYE", "RIGHT",
  "XXX001", "P01", "RIGHT", "EYE", "LEFT",
  "XXX001", "P02", "LEFT", "", "",
)

derive_var_afeye(adae, AELOC, AELAT)