pharmaverse / pharmaverse/logrx

Bug: functions passed to `rlang::exprs` in an R script are not found

Open
#259 20 comments 0 reactions 1 assignee View on GitHub

@bms63 is already working on this.

Since Jan 16, 2025.

bug
Dominant language
HTML
Stars
48
Forks
12
Avg merge
20d 8h
Merged PRs (30d)
1

Description

What happened?

Hi, and thanks for a great package.

Running logrx::axecute from a clean session on the admiral adsl script (https://pharmaverse.github.io/admiral/articles/adsl.html) results in an Error:

Caused by error in `format_eosstt()`:
! could not find function "format_eosstt"

A reproducible example with a smaller script is provided bellow.

Thank you

Session Information

R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: Europe/Budapest
tzcode source: internal

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

other attached packages:
[1] pharmaversesdtm_1.0.0 dplyr_1.1.4 admiral_1.1.1

loaded via a namespace (and not attached):
[1] utf8_1.2.4 generics_0.1.3 tidyr_1.3.1 renv_1.0.9 tcltk_4.4.1 xml2_1.3.6 stringi_1.8.4 hms_1.1.3 digest_0.6.35 magrittr_2.0.3
[11] timechange_0.3.0 fastmap_1.2.0 processx_3.8.4 sessioninfo_1.2.2 backports_1.5.0 ps_1.7.6 promises_1.3.0 admiraldev_1.1.0 purrr_1.0.2 fansi_1.0.6
[21] lintr_3.1.2 lazyeval_0.2.2 cli_3.6.2 shiny_1.8.1.1 rlang_1.1.3 crayon_1.5.2 remotes_2.5.0 withr_3.0.0 tools_4.4.1 logrx_0.3.1
[31] httpuv_1.6.15 vctrs_0.6.5 waiter_0.2.5 cyclocomp_1.1.1 R6_2.5.1 mime_0.12 lifecycle_1.0.4 lubridate_1.9.3 stringr_1.5.1 miniUI_0.1.1.1
[41] pkgconfig_2.0.3 desc_1.4.3 callr_3.7.6 rex_1.2.1 pillar_1.9.0 later_1.3.2 data.table_1.15.4 glue_1.7.0 Rcpp_1.0.12 tibble_3.2.1
[51] tidyselect_1.2.1 rstudioapi_0.16.0 xtable_1.8-4 htmltools_0.5.8.1 compiler_4.4.1

Reproducible Example

Create an adsl_script.R with following contents:

library(admiral)
library(dplyr, warn.conflicts = FALSE)
library(pharmaversesdtm)


data("dm")
data("ds")


dm <- convert_blanks_to_na(dm)
ds <- convert_blanks_to_na(ds)

adsl <- dm %>%
  select(-DOMAIN)

format_eosstt <- function(x) {
  case_when(
    x %in% c("COMPLETED") ~ "COMPLETED",
    x %in% c("SCREEN FAILURE") ~ NA_character_,
    TRUE ~ "DISCONTINUED"
  )
}

adsl <- adsl %>%
  derive_vars_merged(
    dataset_add = ds,
    by_vars = exprs(STUDYID, USUBJID),
    filter_add = DSCAT == "DISPOSITION EVENT",
    new_vars = exprs(EOSSTT = format_eosstt(DSDECOD)),
    missing_values = exprs(EOSSTT = "ONGOING")
  )

from a clean R session create the log for the script:

rm(list = ls())

logrx::axecute(file = "adsl_script.R",
               log_name = "adsl_script.log")

the log will contain:

--------------------------------------------------------------------------------
-                             Errors and Warnings                              -
--------------------------------------------------------------------------------
Errors:
	In argument: `EOSSTT = format_eosstt(DSDECOD)`.

Warnings:

Full log contents:


--------------------------------------------------------------------------------
-                                logrx Metadata                                -
--------------------------------------------------------------------------------
This log was generated using logrx 0.3.1
logrx package version: 0.3.1
logrx build: CRAN (R 4.4.1)
logrx link to repository: https://github.com/pharmaverse/logrx
--------------------------------------------------------------------------------
-                          User and File Information                           -
--------------------------------------------------------------------------------
User: missu
File Name: adsl_script.R
File Path: D:/R/risk
File HashSum: 570a9f5e01c1f82d55098eacbea5c7b576540d74
--------------------------------------------------------------------------------
-                             Session Information                              -
--------------------------------------------------------------------------------
─ Session info ─────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.1 (2024-06-14 ucrt)
 os       Windows 10 x64 (build 19045)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       Europe/Budapest
 date     2024-10-03
 rstudio  2024.09.0+375 Cranberry Hibiscus (desktop)
 pandoc   3.2 @
	  C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\tools\\pandoc.exe

─ Packages ─────────────────────────────────────────────────────────────────────
 package         * version date (UTC) lib source
 admiral         * 1.1.1   2024-06-17 [1] CRAN (R 4.4.1)
 admiraldev        1.1.0   2024-06-06 [1] CRAN (R 4.4.1)
 backports         1.5.0   2024-05-23 [1] CRAN (R 4.4.0)
 callr             3.7.6   2024-03-25 [1] CRAN (R 4.4.0)
 cli               3.6.2   2023-12-11 [1] CRAN (R 4.4.0)
 crayon            1.5.2   2022-09-29 [1] CRAN (R 4.4.0)
 cyclocomp         1.1.1   2023-08-30 [1] CRAN (R 4.4.1)
 data.table        1.15.4  2024-03-30 [1] CRAN (R 4.4.0)
 desc              1.4.3   2023-12-10 [1] CRAN (R 4.4.0)
 digest            0.6.35  2024-03-11 [1] CRAN (R 4.4.0)
 dplyr           * 1.1.4   2023-11-17 [1] CRAN (R 4.4.1)
 fansi             1.0.6   2023-12-08 [1] CRAN (R 4.4.0)
 fastmap           1.2.0   2024-05-15 [1] CRAN (R 4.4.0)
 generics          0.1.3   2022-07-05 [1] CRAN (R 4.4.0)
 glue              1.7.0   2024-01-09 [1] CRAN (R 4.4.0)
 hms               1.1.3   2023-03-21 [1] CRAN (R 4.4.0)
 htmltools         0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
 httpuv            1.6.15  2024-03-26 [1] CRAN (R 4.4.0)
 later             1.3.2   2023-12-06 [1] CRAN (R 4.4.0)
 lazyeval          0.2.2   2019-03-15 [1] CRAN (R 4.4.1)
 lifecycle         1.0.4   2023-11-07 [1] CRAN (R 4.4.0)
 lintr             3.1.2   2024-03-25 [1] CRAN (R 4.4.1)
 logrx             0.3.1   2024-04-12 [1] CRAN (R 4.4.1)
 lubridate         1.9.3   2023-09-27 [1] CRAN (R 4.4.0)
 magrittr          2.0.3   2022-03-30 [1] CRAN (R 4.4.0)
 mime              0.12    2021-09-28 [1] CRAN (R 4.4.0)
 miniUI            0.1.1.1 2018-05-18 [1] CRAN (R 4.4.0)
 pharmaversesdtm * 1.0.0   2024-06-06 [1] CRAN (R 4.4.1)
 pillar            1.9.0   2023-03-22 [1] CRAN (R 4.4.0)
 pkgconfig         2.0.3   2019-09-22 [1] CRAN (R 4.4.0)
 processx          3.8.4   2024-03-16 [1] CRAN (R 4.4.0)
 promises          1.3.0   2024-04-05 [1] CRAN (R 4.4.0)
 ps                1.7.6   2024-01-18 [1] CRAN (R 4.4.0)
 purrr             1.0.2   2023-08-10 [1] CRAN (R 4.4.0)
 R6                2.5.1   2021-08-19 [1] CRAN (R 4.4.0)
 Rcpp              1.0.12  2024-01-09 [1] CRAN (R 4.4.0)
 remotes           2.5.0   2024-03-17 [1] CRAN (R 4.4.0)
 renv              1.0.9   2024-09-23 [1] CRAN (R 4.4.1)
 rex               1.2.1   2021-11-26 [1] CRAN (R 4.4.1)
 rlang             1.1.3   2024-01-10 [1] CRAN (R 4.4.0)
 rstudioapi        0.16.0  2024-03-24 [1] CRAN (R 4.4.0)
 sessioninfo       1.2.2   2021-12-06 [1] CRAN (R 4.4.0)
 shiny             1.8.1.1 2024-04-02 [1] CRAN (R 4.4.0)
 stringi           1.8.4   2024-05-06 [1] CRAN (R 4.4.0)
 stringr           1.5.1   2023-11-14 [1] CRAN (R 4.4.0)
 tibble            3.2.1   2023-03-20 [1] CRAN (R 4.4.0)
 tidyr             1.3.1   2024-01-24 [1] CRAN (R 4.4.0)
 tidyselect        1.2.1   2024-03-11 [1] CRAN (R 4.4.0)
 timechange        0.3.0   2024-01-18 [1] CRAN (R 4.4.0)
 utf8              1.2.4   2023-10-22 [1] CRAN (R 4.4.0)
 vctrs             0.6.5   2023-12-01 [1] CRAN (R 4.4.0)
 waiter            0.2.5   2022-01-03 [1] CRAN (R 4.4.1)
 withr             3.0.0   2024-01-16 [1] CRAN (R 4.4.0)
 xml2              1.3.6   2023-12-04 [1] CRAN (R 4.4.0)
 xtable            1.8-4   2019-04-21 [1] CRAN (R 4.4.0)

 [1] C:/Users/missu/AppData/Local/R/win-library/4.4
 [2] C:/Program Files/R/R-4.4.1/library

─ External software ────────────────────────────────────────────────────────────
 setting        value
 cairo          1.18.0
 cairoFT
 pango
 png            1.6.42
 jpeg           9.6
 tiff           LIBTIFF, Version 4.6.0
 tcl            8.6.13
 curl           8.6.0
 zlib           1.3.1
 bzlib          1.0.8, 13-Jul-2019
 xz             5.4.6
 deflate        1.19
 PCRE           10.43 2024-02-16
 ICU            74.2
 TRE            TRE 0.8.0 R_fixes (BSD)
 iconv          win_iconv
 readline
 BLAS
 lapack
 lapack_version 3.12.0

─ Python configuration ─────────────────────────────────────────────────────────
 Python is not available

────────────────────────────────────────────────────────────────────────────────
--------------------------------------------------------------------------------
-                               Masked Functions                               -
--------------------------------------------------------------------------------
function `ts` from {package:stats} by package:pharmaversesdtm
function `cm` from {package:grDevices} by package:pharmaversesdtm
function `%>%` from {package:admiral} by package:dplyr
function `desc` from {package:admiral} by package:dplyr
function `filter` from {package:stats} by package:dplyr
function `lag` from {package:stats} by package:dplyr
function `intersect` from {package:base} by package:dplyr
function `setdiff` from {package:base} by package:dplyr
function `setequal` from {package:base} by package:dplyr
function `union` from {package:base} by package:dplyr
function `plot` from {package:base} by package:graphics
function `body<-` from {package:base} by package:methods
function `kronecker` from {package:base} by package:methods
--------------------------------------------------------------------------------
-                          Used Package and Functions                          -
--------------------------------------------------------------------------------
{!!! NOT FOUND !!!} format_eosstt
{package:admiral} convert_blanks_to_na, derive_vars_merged, exprs
{package:base} library, c, %in%
{package:dplyr} %>%, select, case_when
{package:utils} data
--------------------------------------------------------------------------------
-                         Program Run Time Information                         -
--------------------------------------------------------------------------------
Start time: 2024-10-03 07:16:26 CEST
End time: 2024-10-03 07:16:27 CEST
Run time: 1 seconds
--------------------------------------------------------------------------------
-                             Errors and Warnings                              -
--------------------------------------------------------------------------------
Errors:
	In argument: `EOSSTT = format_eosstt(DSDECOD)`.

Warnings:
	
--------------------------------------------------------------------------------
-                         Messages, Output, and Result                         -
--------------------------------------------------------------------------------
Messages:
	
Output:
	

Result:
	NULL
--------------------------------------------------------------------------------
-                               Log Output File                                -
--------------------------------------------------------------------------------
Log name: adsl_script.log
Log path: D:/R/risk

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.