Layout-creating function which can be used for creating column-wise summary tables, primarily
used for PK data sets. This function is a wrapper for rtables::analyze_colvars()
.
Arguments
- lyt
(
layout
)
input layout where analyses will be added to.- vars
(
character
)
variable names for the primary analysis variable to be iterated over.- ...
additional arguments for the lower level functions.
- .stats
(
character
)
statistics to select for the table.- .labels
(named
character
)
labels for the statistics (without indent).- labelstr
(
character
)
label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions).- nested
(
flag
)
whether this layout instruction be applied within the existing layout structure if possible (TRUE
, the default) or as a new top-level element (FALSE
). Ignored if it would nest a split underneath analyses, which is not allowed.- na_level
(
string
)
used to replace allNA
or empty values in factors with customstring
.- .formats
(named
character
orlist
)
formats for the statistics.
Value
A layout object suitable for passing to further layouting functions, or to rtables::build_table()
.
Adding this function to an rtable
layout will summarize the given variables, arrange the output
in columns, and add it to the table layout.
Examples
library(dplyr)
adpp <- tern_ex_adpp %>% h_pkparam_sort()
lyt <- basic_table() %>%
split_rows_by(var = "ARM", label_pos = "topleft") %>%
split_rows_by(var = "SEX", label_pos = "topleft") %>%
analyze_vars_in_cols(vars = "AGE")
result <- build_table(lyt = lyt, df = adpp)
result
#> ARM
#> SEX n Mean SD SE CV (%) CV % Geometric Mean
#> ——————————————————————————————————————————————————————————————————————
#> A: Drug X
#> F
#> 0 NA NA NA NA NA
#> M
#> 0 NA NA NA NA NA
#> B: Placebo
#> F
#> 0 NA NA NA NA NA
#> M
#> 0 NA NA NA NA NA
#> C: Combination
#> F
#> 288 36.0 6.3 0.4 17.6 18.0
#> M
#> 234 36.3 8.5 0.6 23.4 23.5
# By selecting just some statistics and ad-hoc labels
lyt <- basic_table() %>%
split_rows_by(var = "ARM", label_pos = "topleft") %>%
split_rows_by(var = "SEX", label_pos = "topleft") %>%
analyze_vars_in_cols(
vars = "AGE",
.stats = c("n", "cv", "geom_mean", "mean_ci", "median", "min", "max"),
.labels = c(
n = "myN",
cv = "myCV",
geom_mean = "myGeomMean",
mean_ci = "Mean (95%CI)",
median = "Median",
min = "Minimum",
max = "Maximum"
)
)
result <- build_table(lyt = lyt, df = adpp)
result
#> ARM
#> SEX myN myCV myGeomMean Mean (95%CI) Median Minimum Maximum
#> ——————————————————————————————————————————————————————————————————————————————————————
#> A: Drug X
#> F
#> 0 NA NA NA NA NA NA
#> M
#> 0 NA NA NA NA NA NA
#> B: Placebo
#> F
#> 0 NA NA NA NA NA NA
#> M
#> 0 NA NA NA NA NA NA
#> C: Combination
#> F
#> 288 17.6 35.5 (35.29, 36.76) 36.8 25.4 49.6
#> M
#> 234 23.4 35.3 (35.19, 37.37) 35.3 23.0 58.3
lyt <- basic_table() %>%
analyze_vars_in_cols(
vars = "AGE",
labelstr = "some custom label"
)
result <- build_table(lyt, df = adpp)
result
#> n Mean SD SE CV (%) CV % Geometric Mean
#> —————————————————————————————————————————————————————————————————————————
#> some custom label 522 36.1 7.4 0.3 20.4 20.6
# PKPT03
lyt <- basic_table() %>%
split_rows_by(var = "TLG_DISPLAY", split_label = "PK Parameter", label_pos = "topleft") %>%
analyze_vars_in_cols(
vars = "AVAL",
.stats = c("n", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"),
.labels = c(
n = "n",
mean = "Mean",
sd = "SD",
cv = "CV (%)",
geom_mean = "Geometric Mean",
geom_cv = "CV % Geometric Mean",
median = "Median",
min = "Minimum",
max = "Maximum"
)
)
result <- build_table(lyt, df = adpp)
result
#> PK Parameter n Mean SD CV (%) Geometric Mean CV % Geometric Mean Median Minimum Maximum
#> —————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> Cmax
#> 58 29.7 5.6 19.0 29.2 19.3 29.0 17.2 45.9
#> AUCinf obs
#> 58 207.5 34.9 16.8 204.5 17.3 202.7 123.4 286.9
#> CL obs
#> 58 5.1 1.0 20.6 5.0 22.7 5.1 2.5 7.4
#> Ae
#> 58 1.5 0.3 21.3 1.5 24.1 1.5 0.6 2.2
#> Fe
#> 58 15.7 3.6 22.7 15.3 24.0 15.8 9.0 22.6
#> CLR
#> 58 0.0 0.0 19.9 0.0 22.2 0.0 0.0 0.1
#> Rmax
#> 58 9.6 2.0 21.1 9.4 21.6 9.3 5.5 14.4
#> Tonset
#> 58 3.0 0.7 22.4 2.9 23.3 3.0 1.7 4.8
#> RENALCLD
#> 58 0.0 0.0 19.0 0.0 19.4 0.0 0.0 0.0