Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate missing row based on subjects not in target data that are in pop_data #29

Closed
elimillera opened this issue Feb 24, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@elimillera
Copy link
Member

adsl <-
  tribble(~ USUBJID, ~TRT,
          "001", "TRTA",
          "002", "TRTB")

adae <-
  tribble(~ USUBJID, ~TRT, ~ AEBODSYS,
          "001", "TRTA", "An AE")

t <- tplyr_table(adae, TRT) %>%
  set_pop_data(adsl) %>%
  add_layer(
    group_count(AEBODSYS) %>%
      set_missing_count(f_str("xx", n), missing = NA)
  )

build(t)
Should result in 
# A tibble: 2 × 4
  row_label1 var1_TRTA    ord_layer_index ord_layer_1
  <chr>      <chr>                  <int>       <dbl>
1 An AE      "1 (100.0%)"               1           1
2 missing    " 1"                       1           2
@elimillera elimillera added the enhancement New feature or request label Feb 24, 2022
@mstackhouse
Copy link
Contributor

So what you'll need to watch out for here is that the subject would be missing rather than NA, so essentially what you're looking for is the number of USUBJID that is in ADAE but not in ADSL for whatever grouping you're examining.

adsl <- haven::read_xpt(url("https://github.com/phuse-org/TestDataFactory/raw/main/Updated/TDF_ADaM/adsl.xpt"))
adae <- haven::read_xpt(url("https://github.com/phuse-org/TestDataFactory/raw/main/Updated/TDF_ADaM/adae.xpt"))

sum(!(adsl$USUBJID %in% unique(adae$USUBJID)))

@mstackhouse
Copy link
Contributor

Closed via #174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants