Skip to content

Commit

Permalink
fix namespace (#418)
Browse files Browse the repository at this point in the history
close #417

---------

Co-authored-by: Emily de la Rua <[email protected]>
  • Loading branch information
clarkliming and edelarua authored Mar 3, 2023
1 parent 9f3d0ce commit 3fe94ba
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 2,111 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ exportMethods(script_funs)
import(dm)
import(dplyr)
import(methods)
import(rlistings)
import(rtables)
import(scda.2022)
import(tern)
Expand All @@ -251,6 +250,7 @@ importFrom(nestcolor,color_palette)
importFrom(rlang,.data)
importFrom(rlang,.env)
importFrom(rlang,sym)
importFrom(rlistings,as_listing)
importFrom(rtables,drop_split_levels)
importFrom(stats,median)
importFrom(stats,quantile)
Expand Down
2 changes: 1 addition & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#' @import dm
#' @import dplyr
#' @import methods
#' @import rlistings
#' @import rtables
#' @import scda.2022
#' @import tern
#' @importFrom rlistings as_listing
#' @importFrom rtables drop_split_levels
#' @importFrom checkmate check_class
#' @importFrom dunlin poly_pivot_wider
Expand Down
26 changes: 16 additions & 10 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,11 @@ syn_test_data <- function() {
# useful for dst01
sd$adsl[["EOSSTT"]] <- as.factor(toupper(sd$adsl[["EOSSTT"]]))

set.seed(321)
sd$adsl <- sd$adsl %>%
mutate(EOTSTT = as.factor(sample(
c("ONGOING", "COMPLETED", "DISCONTINUED"),
nrow(sd$adsl),
replace = TRUE
)))
mutate(EOTSTT = {
set.seed(321)
as.factor(sample(c("ONGOING", "COMPLETED", "DISCONTINUED"), nrow(sd$adsl), replace = TRUE))
})

# useful for lbt04, lbt05
qntls <- sd$adlb %>%
Expand All @@ -169,19 +167,27 @@ syn_test_data <- function() {
),
AVALCAT1 = factor(
case_when(
ANRIND %in% c("HIGH HIGH", "LOW LOW") ~
sample(x = c("LAST", "REPLICATED", "SINGLE"), size = n(), replace = TRUE, prob = c(0.3, 0.6, 0.1)),
ANRIND %in% c("HIGH HIGH", "LOW LOW") ~ {
set.seed(1)
sample(x = c("LAST", "REPLICATED", "SINGLE"), size = n(), replace = TRUE, prob = c(0.3, 0.6, 0.1))
},
TRUE ~ ""
),
levels = c("", "LAST", "REPLICATED", "SINGLE")
)
) %>%
ungroup() %>%
mutate(
PARCAT1 = as.factor(sample(c("CHEMISTRY", "COAGULATION", "HEMATOLOGY"), n(), replace = TRUE)),
PARCAT1 = {
set.seed(2)
as.factor(sample(c("CHEMISTRY", "COAGULATION", "HEMATOLOGY"), n(), replace = TRUE))
},
PARCAT2 = as.factor(case_when(
ANRIND %in% c("HIGH HIGH", "LOW LOW") ~ "LS",
TRUE ~ sample(c("LS", "CV", "SI"), size = n(), replace = TRUE)
TRUE ~ {
set.seed(3)
sample(c("LS", "CV", "SI"), size = n(), replace = TRUE)
}
))
) %>%
select(-q1, -q2)
Expand Down
118 changes: 59 additions & 59 deletions tests/testthat/_snaps/default_tlg.md
Original file line number Diff line number Diff line change
Expand Up @@ -1077,34 +1077,34 @@
———————————————————————————————————————————————————————————————————————————————————————
CHEMISTRY
Alanine Aminotransferase Measurement
Low 4/54 (7.4%) 6/54 (11.1%) 6/50 (12.0%)
High 6/55 (10.9%) 10/54 (18.5%) 8/48 (16.7%)
Low 10/70 (14.3%) 7/65 (10.8%) 6/67 (9.0%)
High 6/70 (8.6%) 6/59 (10.2%) 5/69 (7.2%)
C-Reactive Protein Measurement
Low 8/50 (16.0%) 7/52 (13.5%) 5/50 (10.0%)
High 7/46 (15.2%) 3/49 (6.1%) 3/49 (6.1%)
Low 7/70 (10.0%) 6/78 (7.7%) 9/65 (13.8%)
High 7/67 (10.4%) 7/69 (10.1%) 3/62 (4.8%)
Immunoglobulin A Measurement
Low 4/51 (7.8%) 3/54 (5.6%) 9/61 (14.8%)
High 5/48 (10.4%) 8/56 (14.3%) 9/60 (15.0%)
Low 5/52 (9.6%) 10/64 (15.6%) 8/67 (11.9%)
High 7/50 (14.0%) 8/63 (12.7%) 8/67 (11.9%)
COAGULATION
Alanine Aminotransferase Measurement
Low 5/55 (9.1%) 4/54 (7.4%) 7/50 (14.0%)
High 4/53 (7.5%) 3/52 (5.8%) 8/52 (15.4%)
Low 6/69 (8.7%) 5/67 (7.5%) 6/64 (9.4%)
High 12/67 (17.9%) 7/64 (10.9%) 6/62 (9.7%)
C-Reactive Protein Measurement
Low 7/55 (12.7%) 5/47 (10.6%) 11/68 (16.2%)
High 8/55 (14.5%) 7/44 (15.9%) 7/64 (10.9%)
Low 8/65 (12.3%) 7/68 (10.3%) 6/67 (9.0%)
High 8/63 (12.7%) 5/66 (7.6%) 6/61 (9.8%)
Immunoglobulin A Measurement
Low 2/46 (4.3%) 10/55 (18.2%) 5/48 (10.4%)
High 8/48 (16.7%) 6/59 (10.2%) 6/47 (12.8%)
Low 8/60 (13.3%) 8/69 (11.6%) 2/66 (3.0%)
High 6/62 (9.7%) 8/78 (10.3%) 2/64 (3.1%)
HEMATOLOGY
Alanine Aminotransferase Measurement
Low 5/43 (11.6%) 3/49 (6.1%) 3/52 (5.8%)
High 7/41 (17.1%) 2/43 (4.7%) 7/58 (12.1%)
Low 4/59 (6.8%) 5/63 (7.9%) 10/71 (14.1%)
High 6/58 (10.3%) 7/60 (11.7%) 8/68 (11.8%)
C-Reactive Protein Measurement
Low 9/48 (18.8%) 6/63 (9.5%) 3/48 (6.2%)
High 3/49 (6.1%) 7/55 (12.7%) 2/50 (4.0%)
Low 9/70 (12.9%) 6/57 (10.5%) 12/75 (16.0%)
High 4/63 (6.3%) 3/53 (5.7%) 11/67 (16.4%)
Immunoglobulin A Measurement
Low 6/61 (9.8%) 10/54 (18.5%) 6/52 (11.5%)
High 13/60 (21.7%) 4/58 (6.9%) 6/53 (11.3%)
Low 6/69 (8.7%) 8/67 (11.9%) 9/60 (15.0%)
High 9/71 (12.7%) 4/68 (5.9%) 11/63 (17.5%)

# lbt05_1 functions with default argument value return expected result with test data

Expand All @@ -1114,33 +1114,33 @@
Laboratory Test A: Drug X B: Placebo C: Combination
Direction of Abnormality (N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————
Alanine Aminotransferase Measurement (n) 119 118 112
Alanine Aminotransferase Measurement (n) 129 128 127
Low
Single, not last 0 1 (0.8%) 0
Last or replicated 3 (2.5%) 8 (6.8%) 2 (1.8%)
Any Abnormality 3 (2.5%) 9 (7.6%) 2 (1.8%)
Single, not last 1 (0.8%) 2 (1.6%) 2 (1.6%)
Last or replicated 4 (3.1%) 11 (8.6%) 3 (2.4%)
Any Abnormality 5 (3.9%) 13 (10.2%) 5 (3.9%)
High
Single, not last 1 (0.8%) 1 (0.8%) 0
Last or replicated 5 (4.2%) 8 (6.8%) 5 (4.5%)
Any Abnormality 6 (5.0%) 9 (7.6%) 5 (4.5%)
C-Reactive Protein Measurement (n) 121 116 116
Single, not last 4 (3.1%) 4 (3.1%) 1 (0.8%)
Last or replicated 5 (3.9%) 8 (6.2%) 6 (4.7%)
Any Abnormality 9 (7.0%) 12 (9.4%) 7 (5.5%)
C-Reactive Protein Measurement (n) 128 123 123
Low
Single, not last 2 (1.7%) 1 (0.9%) 0
Last or replicated 4 (3.3%) 5 (4.3%) 5 (4.3%)
Any Abnormality 6 (5.0%) 6 (5.2%) 5 (4.3%)
Single, not last 1 (0.8%) 0 3 (2.4%)
Last or replicated 11 (8.6%) 7 (5.7%) 4 (3.3%)
Any Abnormality 12 (9.4%) 7 (5.7%) 7 (5.7%)
High
Single, not last 0 1 (0.9%) 1 (0.9%)
Last or replicated 7 (5.8%) 5 (4.3%) 6 (5.2%)
Any Abnormality 7 (5.8%) 6 (5.2%) 7 (6.0%)
Immunoglobulin A Measurement (n) 109 124 114
Single, not last 2 (1.6%) 1 (0.8%) 2 (1.6%)
Last or replicated 9 (7.0%) 10 (8.1%) 11 (8.9%)
Any Abnormality 11 (8.6%) 11 (8.9%) 13 (10.6%)
Immunoglobulin A Measurement (n) 126 125 119
Low
Single, not last 1 (0.9%) 0 1 (0.9%)
Last or replicated 4 (3.7%) 6 (4.8%) 5 (4.4%)
Any Abnormality 5 (4.6%) 6 (4.8%) 6 (5.3%)
Single, not last 1 (0.8%) 3 (2.4%) 4 (3.4%)
Last or replicated 6 (4.8%) 6 (4.8%) 7 (5.9%)
Any Abnormality 7 (5.6%) 9 (7.2%) 11 (9.2%)
High
Single, not last 0 0 1 (0.9%)
Last or replicated 2 (1.8%) 6 (4.8%) 4 (3.5%)
Any Abnormality 2 (1.8%) 6 (4.8%) 5 (4.4%)
Single, not last 1 (0.8%) 1 (0.8%) 2 (1.7%)
Last or replicated 3 (2.4%) 8 (6.4%) 4 (3.4%)
Any Abnormality 4 (3.2%) 9 (7.2%) 6 (5.0%)

# lbt07_1 functions with default argument value return expected result with test data

Expand All @@ -1151,19 +1151,19 @@
Direction of Abnormality A: Drug X B: Placebo C: Combination
Highest NCI CTCAE Grade (N=134) (N=134) (N=132)
———————————————————————————————————————————————————————————————————————————————————
Alanine Aminotransferase Measurement (n) 134 134 132
Alanine Aminotransferase Measurement (n) 134 133 132
LOW
1 14 (10.4%) 15 (11.2%) 10 (7.6%)
2 13 (9.7%) 18 (13.4%) 11 (8.3%)
1 14 (10.4%) 15 (11.3%) 10 (7.6%)
2 13 (9.7%) 18 (13.5%) 11 (8.3%)
3 20 (14.9%) 12 (9.0%) 10 (7.6%)
4 7 (5.2%) 8 (6.0%) 10 (7.6%)
Any 54 (40.3%) 53 (39.6%) 41 (31.1%)
Any 54 (40.3%) 53 (39.8%) 41 (31.1%)
HIGH
1 18 (13.4%) 16 (11.9%) 18 (13.6%)
2 15 (11.2%) 13 (9.7%) 18 (13.6%)
3 10 (7.5%) 16 (11.9%) 13 (9.8%)
4 12 (9.0%) 11 (8.2%) 13 (9.8%)
Any 55 (41.0%) 56 (41.8%) 62 (47.0%)
1 18 (13.4%) 16 (12.0%) 18 (13.6%)
2 15 (11.2%) 13 (9.8%) 17 (12.9%)
3 10 (7.5%) 16 (12.0%) 13 (9.8%)
4 12 (9.0%) 11 (8.3%) 13 (9.8%)
Any 55 (41.0%) 56 (42.1%) 61 (46.2%)
C-Reactive Protein Measurement (n) 134 134 132
LOW
1 16 (11.9%) 19 (14.2%) 15 (11.4%)
Expand All @@ -1177,19 +1177,19 @@
3 16 (11.9%) 12 (9.0%) 14 (10.6%)
4 12 (9.0%) 12 (9.0%) 10 (7.6%)
Any 60 (44.8%) 55 (41.0%) 46 (34.8%)
Immunoglobulin A Measurement (n) 134 134 132
Immunoglobulin A Measurement (n) 133 133 132
LOW
1 17 (12.7%) 23 (17.2%) 17 (12.9%)
2 12 (9.0%) 15 (11.2%) 14 (10.6%)
3 15 (11.2%) 11 (8.2%) 14 (10.6%)
4 10 (7.5%) 16 (11.9%) 10 (7.6%)
Any 54 (40.3%) 65 (48.5%) 55 (41.7%)
1 17 (12.8%) 23 (17.3%) 17 (12.9%)
2 12 (9.0%) 15 (11.3%) 14 (10.6%)
3 15 (11.3%) 11 (8.3%) 14 (10.6%)
4 10 (7.5%) 16 (12.0%) 10 (7.6%)
Any 54 (40.6%) 65 (48.9%) 55 (41.7%)
HIGH
1 25 (18.7%) 14 (10.4%) 13 (9.8%)
2 14 (10.4%) 20 (14.9%) 16 (12.1%)
3 12 (9.0%) 13 (9.7%) 17 (12.9%)
4 11 (8.2%) 13 (9.7%) 4 (3.0%)
Any 62 (46.3%) 60 (44.8%) 50 (37.9%)
1 25 (18.8%) 14 (10.5%) 13 (9.8%)
2 14 (10.5%) 19 (14.3%) 16 (12.1%)
3 12 (9.0%) 12 (9.0%) 17 (12.9%)
4 11 (8.3%) 13 (9.8%) 4 (3.0%)
Any 62 (46.6%) 58 (43.6%) 50 (37.9%)

# lbt14_1 functions with default argument value return expected result with test data

Expand Down
Loading

0 comments on commit 3fe94ba

Please sign in to comment.