pharmaverse / admiral

ADaM in R Asset Library
https://pharmaverse.github.io/admiral
Apache License 2.0
215 stars 60 forks source link

Bug: derive_vars_merged_lookup() arg: duplicate_msg does not work for specific changes #2465

Closed WangLaoK closed 1 month ago

WangLaoK commented 1 month ago

What happened?

Dear Admiral team,

I try to specific my duplicated msg from default parameters.

But the default parameters cannot pass the argument I used. See below:

image

It prints as dataset_add instead of vs.lut.

Is there any guidance for this duplicate message changes?

Regards, Hans

Session Information

R version 4.3.1 (2023-06-16) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux

Matrix products: default BLAS/LAPACK: /CHBS/apps/EB/software/imkl/2022.1.0-gompi-2022a/mkl/2022.1.0/lib/intel64/libmkl_gf_lp64.so.2; LAPACK version 3.9.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Europe/Zurich tzcode source: system (glibc)

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] admiral_1.0.2 brave_1.4.0 arsenal_3.6.3 tidyselect_1.2.0 data.table_1.14.8 rvest_1.0.3
[7] xml2_1.3.5 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.3 purrr_1.0.2
[13] readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.3 tidyverse_2.0.0 haven_2.5.3

loaded via a namespace (and not attached): [1] utf8_1.2.3 generics_0.1.3 stringi_1.7.12 hms_1.1.3 magrittr_2.0.3 grid_4.3.1
[7] timechange_0.2.0 processx_3.8.2 zip_2.3.0 ps_1.7.5 admiraldev_1.0.0 httr_1.4.7
[13] fansi_1.0.4 scales_1.2.1 textshaping_0.3.6 cli_3.6.1 rlang_1.1.1 munsell_0.5.0
[19] withr_2.5.0 tools_4.3.1 officer_0.6.2 tzdb_0.4.0 uuid_1.1-1 colorspace_2.1-0 [25] vctrs_0.6.3 R6_2.5.1 lifecycle_1.0.3 ragg_1.2.5 pkgconfig_2.0.3 callr_3.7.3
[31] pillar_1.9.0 gtable_0.3.4 glue_1.6.2 systemfonts_1.0.4 rstudioapi_0.15.0 compiler_4.3.1
[37] askpass_1.2.0 openssl_2.1.0

Reproducible Example

No response

bundfussr commented 1 month ago

Hi @WangLaoK ,

cli formatting was introduced in admiral 1.1.0 and admiraldev 1.1.0 but you are using admiral 1.0.2. Therefore the error message is not formatted correctly.

With the newest admiral version you should get

> derive_vars_merged_lookup(
+     dataset = vs,
+     dataset_add = param_lookup,
+     by_vars = exprs(VSTESTCD),
+     new_vars = exprs(PARAMCD, PARAM),
+     print_not_mapped = TRUE,
+     duplicate_msg = "Dataset {.arg dataset_add} contains duplicate records with respect to {.var {vars2chr(by_vars)}}."
+ )
Error in `signal_duplicate_records()` at admiral/R/derive_merged.R:398:5:
! Dataset `dataset_add` contains duplicate records with respect to `VSTESTCD`.
ℹ Run admiral::get_duplicates_dataset() to access the duplicate records
Run `rlang::last_trace()` to see where the error occurred.

If you don't want to display "dataset_add" in the error message, you need to change the call to


> derive_vars_merged_lookup(
+     dataset = vs,
+     dataset_add = param_lookup,
+     by_vars = exprs(VSTESTCD),
+     new_vars = exprs(PARAMCD, PARAM),
+     print_not_mapped = TRUE,
+     duplicate_msg = "Dataset {.arg param_lookup} contains duplicate records with respect to {.var {vars2chr(by_vars)}}."
+ )
Error in `signal_duplicate_records()` at admiral/R/derive_merged.R:398:5:
! Dataset `param_lookup` contains duplicate records with respect to `VSTESTCD`.
ℹ Run admiral::get_duplicates_dataset() to access the duplicate records
Run `rlang::last_trace()` to see where the error occurred.```
WangLaoK commented 1 month ago

Hi @bundfussr , thanks for the quick response and sorry for the late reply. Took some time to install new version.

After install version 1.1.0, duplicated msg works fine for me. Please close the issue.