insightsengineering / teal.gallery

A Gallery of Exploratory Web Apps used for Analyzing Clinical Trial Data
https://insightsengineering.github.io/teal.gallery/
Other
29 stars 7 forks source link

[Bug]: Addtional linebreaks are found in code. #113

Open kartikeyakirar opened 11 months ago

kartikeyakirar commented 11 months ago

What happened?

Tested on refactor branch.

In application, across any module, clicking on Show Code displays the code with excessive line breaks. This issue specifically occurs for the code passed in within function to create teal_data .

image

Initial investigation: No additional line breaks are found when teal_data is initially created. For example:

data <- cdisc_data() |>
  within({
    library(nestcolor)
    ADSL <- rADSL
    ADRS <- rADRS
    ADTR <- rADTR
    ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX))
  })

datanames(data) <- c("ADSL", "ADTR", "ADRS")
join_keys(data) <- default_cdisc_join_keys[datanames(data)]

The get_code function returns the following result:

> get_code(data)
[1] "library(nestcolor)\nADSL <- rADSL\nADRS <- rADRS\nADTR <- rADTR\nADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX))"

However, additional line breaks are observed when application data is passed to modules. click Show code button result.

app <- init(
  data = data,
  modules = modules(
    tm_g_waterfall(
      label = "Waterfall",
      dataname_tr = "ADTR",
      dataname_rs = "ADRS",
      bar_paramcd = choices_selected(c("SLDINV"), "SLDINV"),
      bar_var = choices_selected(c("PCHG", "AVAL"), "PCHG"),
      bar_color_var = choices_selected(c("ARMCD", "SEX"), "ARMCD"),
      bar_color_opt = NULL,
      sort_var = choices_selected(c("ARMCD", "SEX"), NULL),
      add_label_var_sl = choices_selected(c("SEX", "EOSDY"), NULL),
      add_label_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL),
      anno_txt_var_sl = choices_selected(c("SEX", "ARMCD", "BMK1", "BMK2"), NULL),
      anno_txt_paramcd_rs = choices_selected(c("BESRSPI", "OBJRSPI"), NULL),
      facet_var = choices_selected(c("SEX", "ARMCD", "STRATA1", "STRATA2"), NULL),
      href_line = "-30, 20"
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}