Merck / metalite

An R package to create metadata structure for ADaM data analysis and reporting
https://merck.github.io/metalite/
GNU General Public License v3.0
15 stars 5 forks source link

bug fix: keep factor rows with completely missing values #165

Closed fb-elong closed 2 months ago

fb-elong commented 2 months ago

The factor with empty factor should have a row as output

meta <- meta_example() |>
  define_parameter(name = "sex", var = "SEX1", label = "Sex")
meta$data_population$SEX1 <- factor(meta$data_population$SEX, c("M", "F", "Other"))
collect_n_subject(meta, "apat", "sex")
                name     Placebo Xanomeline Low Dose Xanomeline High Dose        Total
1 Number of Subjects          86                  84                   84          254
2                Sex        <NA>                <NA>                 <NA>         <NA>
3 Subjects with Data          86                  84                   84          254
4                  M 33 ( 38.4%)         34 ( 40.5%)          44 ( 52.4%) 111 ( 43.7%)
5                  F 53 ( 61.6%)         50 ( 59.5%)          40 ( 47.6%) 143 ( 56.3%)
6              Other  0 (  0.0%)          0 (  0.0%)           0 (  0.0%)   0 (  0.0%)

Also tested in metalite.table1 that works as expected after the code change.

metalite.table1::metalite_table1(~ SEX1 | TRTA, data = meta$data_population)

image