Skip to content

Commit bbe42cb

Browse files
iaugustyshajoezhugithub-actions[bot]
authored
test(JnJ): ✅ Added table_jnj_tbl1 (#196)
Added a test to check that a factor variable with all values missing would produce a correct table using tern::analyze_vars --------- Signed-off-by: Joe Zhu <[email protected]> Co-authored-by: Joe Zhu <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent a3b5bed commit bbe42cb

File tree

4 files changed

+80
-3
lines changed

4 files changed

+80
-3
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Depends:
2525
R (>= 4.2),
2626
rlistings (>= 0.2.10),
2727
rtables (>= 0.6.11.9017),
28-
tern (>= 0.9.7.9018)
28+
tern (>= 0.9.9.9003)
2929
Imports:
3030
pharmaverseadam (>= 1.1.0.9001),
3131
random.cdisc.data (>= 0.3.16)
@@ -56,4 +56,4 @@ Encoding: UTF-8
5656
Language: en-US
5757
LazyData: true
5858
Roxygen: list(markdown = TRUE)
59-
RoxygenNote: 7.3.2
59+
RoxygenNote: 7.3.3

man/scda.test-package.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# DMT01 variant factor with only Missing values
2+
3+
Code
4+
res
5+
Output
6+
Placebo Screen Failure Xanomeline High Dose Xanomeline Low Dose
7+
(N=86) (N=52) (N=72) (N=96)
8+
——————————————————————————————————————————————————————————————————————————————————————————————————
9+
Age (yr)
10+
n 86 52 72 96
11+
Mean (SD) 75.2 (8.6) 75.1 (9.7) 73.8 (7.9) 76.0 (8.1)
12+
Median 76.0 76.0 75.5 78.0
13+
Min - Max 52.0 - 89.0 50.0 - 89.0 56.0 - 88.0 51.0 - 88.0
14+
Age Group
15+
n 86 52 72 96
16+
18-40 0 0 0 0
17+
41-64 14 (16.3%) 9 (17.3%) 11 (15.3%) 8 (8.3%)
18+
>=65 72 (83.7%) 43 (82.7%) 61 (84.7%) 88 (91.7%)
19+
Biomarker 1 Categories
20+
n 0 0 0 0
21+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# extra special case situation to scenario from test-table_dmt01.R
2+
# Tests DMT01 with corner case situation to demonstrate bug in analyze is resolved with empty factor data
3+
# tern@1431-bug-s_summaryfactor
4+
set.seed(1)
5+
6+
adsl <- pharmaverseadam::adsl
7+
adsl <- adsl %>%
8+
mutate(BMRKR1 = rnorm(nrow(adsl), 3.5, 10)) %>%
9+
mutate(STRATA1 = factor(sample(c("A", "B", "C"), nrow(adsl), TRUE)))
10+
11+
adsl <- df_explicit_na(adsl)
12+
13+
adsl <- adsl %>%
14+
mutate(
15+
SEX = factor(case_when(
16+
SEX == "M" ~ "Male",
17+
SEX == "F" ~ "Female",
18+
SEX == "U" ~ "Unknown",
19+
SEX == "UNDIFFERENTIATED" ~ "Undifferentiated"
20+
)),
21+
AGEGR1 = factor(
22+
case_when(
23+
between(AGE, 18, 40) ~ "18-40",
24+
between(AGE, 41, 64) ~ "41-64",
25+
AGE > 64 ~ ">=65"
26+
),
27+
levels = c("18-40", "41-64", ">=65")
28+
),
29+
BMRKR1_CAT = NA_character_
30+
) %>%
31+
var_relabel(
32+
BMRKR1_CAT = "Biomarker 1 Categories"
33+
)
34+
35+
adsl <- df_explicit_na(adsl, na_level = "<Missing>")
36+
37+
38+
testthat::test_that("DMT01 variant factor with only Missing values", {
39+
vars <- c("AGE", "AGEGR1", "BMRKR1_CAT")
40+
var_labels <- c(
41+
"Age (yr)",
42+
"Age Group",
43+
"Biomarker 1 Categories"
44+
)
45+
46+
result <- basic_table(show_colcounts = TRUE) %>%
47+
split_cols_by(var = "ACTARM") %>%
48+
analyze_vars(
49+
vars = vars,
50+
var_labels = var_labels
51+
) %>%
52+
build_table(adsl)
53+
54+
res <- testthat::expect_silent(result)
55+
testthat::expect_snapshot(res)
56+
})

0 commit comments

Comments
 (0)