insightsengineering / teal.modules.clinical

Provides teal modules for the standard clinical trials outputs
https://insightsengineering.github.io/teal.modules.clinical/
Other
32 stars 17 forks source link

Unused parameters in tm_g_lineplot(): need to specify the package source for g_lineplot() #613

Open puzeng opened 2 years ago

puzeng commented 2 years ago

What happened?

Getting error messages like "unused parameters in tm_g_lineplot()".

Possibly because: Loaded both packages: goshawk and tern where both of them have a same function, g_lineplot(). It might call the g_lineplot in goshawk rather than the correct one, in tern.

Could we change line 129 in source code to _tern::glineplot() to avoid this kind of error (https://github.com/insightsengineering/teal.modules.clinical/blob/main/R/tm_g_lineplot.R)? Feel free to reach out for questions and thank you! :)

sessionInfo()

No response

Relevant log output

No response

Code of Conduct

Contribution Guidelines

Security Policy

donyunardi commented 2 years ago

Thanks for raising this, @puzeng ! I was able to reproduce the issue by using the example code in tm_g_lineplot() roxygen as a base and added goshawk and tern to my library call:

library(scda)
library(nestcolor)
library(teal.modules.clinical)
library(goshawk)
library(tern)

ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADLB <- synthetic_cdisc_dataset("latest", "adlb")

ADLB <- dplyr::mutate(ADLB, AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min))

app <- init(
  data = cdisc_data(
    cdisc_dataset("ADSL", ADSL,
      code = 'ADSL <- synthetic_cdisc_dataset("latest", "adsl")'
    ),
    cdisc_dataset("ADLB", ADLB,
      code = 'ADLB <- synthetic_cdisc_dataset("latest", "adlb")
        ADLB <- dplyr::mutate(ADLB, AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min))' # nolint
    )
  ),
  modules = modules(
    tm_g_lineplot(
      label = "Line Plot",
      dataname = "ADLB",
      strata = choices_selected(
        variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
        "ARM"
      ),
      y = choices_selected(
        variable_choices(ADLB, c("AVAL", "BASE", "CHG", "PCHG")),
        "AVAL"
      ),
      param = choices_selected(
        value_choices(ADLB, "PARAMCD", "PARAM"),
        "ALT"
      )
    )
  )
)
if (interactive()) {
  shinyApp(ui = app$ui, server = app$server)
}

image

tagging @shajoezhu for awareness. As suggested by author, this is a masking issue where functions are the same name:

shajoezhu commented 2 years ago

Thanks @puzeng and @donyunardi , I was just wondering if you want to acutally use the goshawk and teal.goshawk packages in this case? see https://github.com/insightsengineering/teal.goshawk/blob/main/R/tm_g_gh_lineplot.R

donyunardi commented 1 year ago

Linking this issue with: insightsengineering/goshawk/issues/172