Skip to content

[Bug]: Decorators does not work for tm_a_pca's output eigenvector_plot #848

@vedhav

Description

@vedhav

What happened?

Example to reproduce:

devtools::load_all()

data <- teal_data(join_keys = default_cdisc_join_keys[c("ADSL", "ADRS")])
data <- within(data, {
  require(nestcolor)
  ADSL <- rADSL
  ADRS <- rADRS
})

# For tm_outliers
fact_vars_adsl <- names(Filter(isTRUE, sapply(data[["ADSL"]], is.factor)))
vars <- choices_selected(variable_choices(data[["ADSL"]], fact_vars_adsl))

caption_decorator <- function(default_caption = "I am a good decorator", .var_to_replace = "plot") {
  print(.var_to_replace)
  teal_transform_module(
    label = "Caption",
    ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption),
    server = make_teal_transform_server(
      substitute(
        {
          .var_to_replace <- .var_to_replace + ggplot2::labs(caption = footnote)
        },
        env = list(.var_to_replace = as.name(.var_to_replace))
      )
    )
  )
}

init(
  data = data,
  modules = modules(
    tm_a_pca(
      "PCA",
      dat = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          choices = variable_choices(data = data[["ADSL"]], c("BMRKR1", "AGE", "EOSDY")),
          selected = c("BMRKR1", "AGE")
        )
      ),
      decorators = list(
        eigenvector_plot = caption_decorator("I am a eigenvector_plot", "eigenvector_plot")
      )
    )
  )
) |> shiny::runApp()

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcore

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions