Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add `var = ...` to `define_population` and `define_observation`

Open
#107 0 comments 0 reactions 1 assignee View on GitHub

@lm3388 is already working on this.

Since Apr 14, 2026.

Assessment

This issue has not been assessed yet.

Description

Add var = ... to define_population() and define_observation() in the vignette of https://merck.github.io/forestly/articles/forestly.html like code below.

adsl <- r2rtf::r2rtf_adsl |> 
  filter(TRT01P %in% c("Placebo", "Xanomeline High Dose")) |>
  mutate(TRT01P = factor(TRT01P,
                         levels = c("Placebo", "Xanomeline High Dose"),
                         labels = c("Control", "Experimental")),
         TRT01A = factor(TRT01A,
                         levels = c("Placebo", "Xanomeline High Dose"),
                         labels = c("Control", "Experimental")),
         RACE = stringr::str_to_sentence(RACE))

adae <- forestly_adae |> 
  filter(TRTA %in% c("Placebo", "Xanomeline High Dose")) |>
  rename(TRT01A = TRTA) |>
  mutate(TRT01A = factor(TRT01A,
                         levels = c("Placebo", "Xanomeline High Dose"),
                         labels = c("Control", "Experimental")))

meta_ae_forest <- meta_adam(population = adsl, 
                            observation = adae) |>
  define_plan(plan = plan(analysis = "ae_forestly",
                          population = "apat",
                          observation = "apat",
                          parameter = "any;drug-related;serious;drug-related-serious")) |>
  define_analysis(name = "ae_forestly", 
                  label = "Interactive Forest Plot") |>
  define_population(name = "apat", 
                    group = "TRT01A", 
                    id = "USUBJID",
                    subset = SAFFL == "Y", 
                    label = "All Patient as Treated",
                    var = c("USUBJID", "SAFFL", "TRT01A", "SITEID", "SEX", "RACE", "AGE")) |>
  define_observation(name = "apat", 
                     group = "TRT01A",
                     subset = SAFFL == "Y", 
                     label = "All Patient as Treated",
                     var = c("USUBJID", "SAFFL", "TRT01A", "AEDECOD", "AEBODSYS", 
                             "AEREL", "AESER", "AEOUT", "AEACN", "AESDTH", "ASTDT", "AENDT")
                     ) |>
  define_parameter(name = "any",
                   subset = NULL,
                   label = "Any AEs",
                   var = "AEDECOD", 
                   soc = "AEBODSYS") |>
  define_parameter(name = "drug-related",
                   subset = toupper(AEREL) %in% c("PROBABLE", "POSSIBLE"),
                   label = "Drug-related AEs",
                   var = "AEDECOD", soc = "AEBODSYS") |>
  define_parameter(name = "serious",
                   subset = AESER == "Y",
                   label = "Serious AEs",
                   var = "AEDECOD", soc = "AEBODSYS") |>
  define_parameter(name = "drug-related-serious",
                   subset = AESER == "Y" & toupper(AEREL) %in% c("PROBABLE", "POSSIBLE"),
                   label = "Drug-related serious AEs",
                   var = "AEDECOD", soc = "AEBODSYS") |>
  meta_build()

meta_ae_forest |>
  prepare_ae_forestly(ae_listing_display = c("USUBJID", "SITEID", "SEX", "RACE", "AGE",
                                             "AEREL", "AESER", "AEOUT", "AEACN", "AESDTH", "ASTDT", "AENDT")) |>
  format_ae_forestly(display = c("n", "prop", "fig_prop", "fig_diff")) |>
  ae_forestly()
Dominant language
R
Stars
22
Forks
6
Avg merge
1d 13h
Merged PRs (30d)
10

Contributor guide

No contributing guide indexed for this repository

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.

More from Merck/forestly

All issues in Merck/forestly

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.