Skip to content

Commit

Permalink
Fix analyze_vars_in_cols usage (#101)
Browse files Browse the repository at this point in the history
Closes #50
  • Loading branch information
edelarua committed Aug 22, 2023
1 parent 2288df2 commit d9380ba
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 152 deletions.
5 changes: 3 additions & 2 deletions book/tables/pharmacokinetic/adat03.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ lyt <- basic_table() %>%
split_rows_by(
var = "VISIT",
label_pos = "topleft",
split_label = "Visit"
split_label = "Visit",
split_fun = drop_split_levels,
child_labels = "hidden"
) %>%
analyze_vars_in_cols(
vars = c(rep("AVAL", 8), "AVAL_LT"),
Expand Down Expand Up @@ -126,5 +128,4 @@ result
```

{{< include ../../repro.qmd >}}

:::
30 changes: 15 additions & 15 deletions book/tables/pharmacokinetic/pkct01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ library(tern)
adpc <- synthetic_cdisc_dataset("latest", "adpc")
# Helper function
threesigfmt <- function(x, ...) {
as.character(signif(x, 3))
}
```

## Standard Table (Stats in Columns)

```{r variant1, test = list(result_v1 = "result")}
# Setting up the data
adpc_1 <- adpc %>%
mutate(
NFRLT = as.factor(NFRLT),
AVALCAT1 = as.factor(AVALCAT1)
) %>%
filter(ACTARM %in% c("A: Drug X")) %>%
filter(ACTARM == "A: Drug X", PARAM == "Plasma Drug X") %>%
mutate(ACTARM = factor(ACTARM, levels = c("A: Drug X"))) %>%
select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1)
# Helper function
threesigfmt <- function(x, ...) {
as.character(signif(x, 3))
}
```

## Standard Table (Stats in Columns)

```{r variant1, test = list(result_v1 = "result")}
# Row structure
l_rows <- basic_table() %>%
split_rows_by(
Expand All @@ -53,7 +53,8 @@ l_rows <- basic_table() %>%
split_rows_by(
var = "NFRLT",
split_label = "Norminal Time from First Dose",
label_pos = "topleft"
label_pos = "topleft",
child_labels = "hidden"
)
# Column results for numeric values
Expand All @@ -79,7 +80,7 @@ lyt <- l_rows %>%
),
.labels = c(
n = "n",
n_blq = "Number\nof\n<LTR/BLQ>s",
n_blq = "Number\nof\nLTRs/BLQs",
mean = "Mean",
sd = "SD",
cv = "CV (%) Mean",
Expand All @@ -94,8 +95,8 @@ lyt <- l_rows %>%
result <- build_table(lyt, df = adpc_1) %>% prune_table()
# Decorating
main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable\n Protocol: xxxxx"
subtitles(result) <- paste("Analyte: ", unique(unique(adpc$PARAM)), "Treatment:", unique(unique(adpc$ACTARM)))
main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable"
subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM)))
main_footer(result) <- "NE: Not Estimable"
result
```
Expand All @@ -111,5 +112,4 @@ result
```

{{< include ../../repro.qmd >}}

:::
4 changes: 2 additions & 2 deletions book/tables/pharmacokinetic/pkpt03.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ lyt <- basic_table() %>%
split_rows_by(
var = "PKPARAM",
label_pos = "topleft",
split_label = "PK Parameter"
split_label = "PK Parameter",
child_labels = "hidden"
) %>%
analyze_vars_in_cols(
vars = "AVAL",
Expand Down Expand Up @@ -110,5 +111,4 @@ result
```

{{< include ../../repro.qmd >}}

:::
4 changes: 2 additions & 2 deletions book/tables/pharmacokinetic/pkpt05.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ lyt <- basic_table() %>%
split_rows_by(
var = "PKPARAM",
label_pos = "topleft",
split_label = "PK Parameter"
split_label = "PK Parameter",
child_labels = "hidden"
) %>%
analyze_vars_in_cols(
vars = "AVAL",
Expand Down Expand Up @@ -110,5 +111,4 @@ result
```

{{< include ../../repro.qmd >}}

:::
4 changes: 2 additions & 2 deletions book/tables/pharmacokinetic/pkpt07.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ lyt <- basic_table() %>%
split_rows_by(
var = "PKPARAM",
label_pos = "topleft",
split_label = "PK Parameter"
split_label = "PK Parameter",
child_labels = "hidden"
) %>%
analyze_vars_in_cols(
vars = "AVAL",
Expand Down Expand Up @@ -111,5 +112,4 @@ result
```

{{< include ../../repro.qmd >}}

:::
16 changes: 4 additions & 12 deletions package/tests/testthat/_snaps/adat03/markdown-snaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,12 @@
Samples {1} Mean SD Median Minimum Maximum CV (%) Geometric Mean ≤ 15μg/mL {2}
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
A: Drug X (N=536)
Day 1
Day 1 402 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 NA NA 402 (100%)
Day 2
Day 2 134 1.618e+01 1.626e+00 1.619e+01 1.260e+01 1.986e+01 10.0 1.610e+01 39 (29.1%)
<Missing>
<Missing> 0 NA NA NA NA NA NA NA NA
Day 1 402 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 NA NA 402 (100%)
Day 2 134 1.618e+01 1.626e+00 1.619e+01 1.260e+01 1.986e+01 10.0 1.610e+01 39 (29.1%)
C: Combination (N=792)
Day 1
Day 1 528 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 NA NA 528 (100%)
Day 2
Day 2 264 2.468e+01 8.645e+00 2.251e+01 1.264e+01 3.947e+01 35.0 2.315e+01 28 (10.6%)
<Missing>
<Missing> 0 NA NA NA NA NA NA NA NA
Day 1 528 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 NA NA 528 (100%)
Day 2 264 2.468e+01 8.645e+00 2.251e+01 1.264e+01 3.947e+01 35.0 2.315e+01 28 (10.6%)
Overall 1328 6.540e+00 1.095e+01 0.000e+00 0.000e+00 3.947e+01 167.5 NA 997 (75.1%)
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Expand Down
60 changes: 24 additions & 36 deletions package/tests/testthat/_snaps/pkct01/markdown-snaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,31 @@
print(data_snap[[i]])
Output
Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable
Protocol: xxxxx
Analyte: Plasma Drug X Treatment: A: Drug X
Analyte: Urine Drug X Treatment: C: Combination
Analyte: Urine Drug Y Treatment: A: Drug X
Analyte: Plasma Drug Y Treatment: C: Combination
Protocol: xxxxx
Analyte: Plasma Drug X
Treatment: A: Drug X
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Cohort/Treatment
Visit
Norminal Time from First Dose Number
of
n <LTR/BLQ>s Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
A: Drug X
Day 1
0
0 402 402 0 0 NE NE NE 0 0 0
0.5
0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6
1
1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9
1.5
1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19
2
2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5
3
3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9
4
4 402 0 4.79 1.01 21.2 4.69 21.9 4.79 2.7 7.09
8
8 402 0 0.348 0.179 51.6 0.303 58.2 0.318 0.076 0.866
12
12 402 0 0.0224 0.0189 84.4 0.0156 111.2 0.017 0.002 0.083
Day 2
24
24 402 402 0 0 NE NE NE 0 0 0
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Cohort/Treatment
Visit
Norminal Time from First Dose Number
of
n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
A: Drug X
Day 1
0 134 134 0 0 NE NE NE 0 0 0
0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6
1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9
1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19
2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5
3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9
4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09
8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866
12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083
Day 2
24 134 134 0 0 NE NE NE 0 0 0
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
NE: Not Estimable

Loading

0 comments on commit d9380ba

Please sign in to comment.