split_cols_by_cuts | R Documentation |
Create columns (or row splits) based on values (such as quartiles) of
var
.
split_cols_by_cuts(
lyt,
var,
cuts,
cutlabels = NULL,
split_label = var,
nested = TRUE,
cumulative = FALSE
)
split_rows_by_cuts(
lyt,
var,
cuts,
cutlabels = NULL,
split_label = var,
format = NULL,
na_str = NA_character_,
nested = TRUE,
cumulative = FALSE,
label_pos = "hidden",
section_div = NA_character_
)
split_cols_by_cutfun(
lyt,
var,
cutfun = qtile_cuts,
cutlabelfun = function(x) NULL,
split_label = var,
nested = TRUE,
extra_args = list(),
cumulative = FALSE
)
split_cols_by_quartiles(
lyt,
var,
split_label = var,
nested = TRUE,
extra_args = list(),
cumulative = FALSE
)
split_rows_by_quartiles(
lyt,
var,
split_label = var,
format = NULL,
na_str = NA_character_,
nested = TRUE,
child_labels = c("default", "visible", "hidden"),
extra_args = list(),
cumulative = FALSE,
indent_mod = 0L,
label_pos = "hidden",
section_div = NA_character_
)
split_rows_by_cutfun(
lyt,
var,
cutfun = qtile_cuts,
cutlabelfun = function(x) NULL,
split_label = var,
format = NULL,
na_str = NA_character_,
nested = TRUE,
child_labels = c("default", "visible", "hidden"),
extra_args = list(),
cumulative = FALSE,
indent_mod = 0L,
label_pos = "hidden",
section_div = NA_character_
)
lyt |
layout object pre-data used for tabulation |
var |
string, variable name |
cuts |
numeric. Cuts to use |
cutlabels |
character (or NULL). Labels for the cuts |
split_label |
string. Label string to be associated with the table generated by the split. Not to be confused with labels assigned to each child (which are based on the data and type of split during tabulation). |
nested |
boolean. Should this layout instruction be applied within the
existing layout structure if possible ( |
cumulative |
logical. Should the cuts be treated as cumulative. Defaults
to |
format |
|
na_str |
character(1). String that should be displayed when the value of |
label_pos |
character(1). Location the variable label should be
displayed, Accepts |
section_div |
character(1). String which should be repeated as a section
divider after each group defined by this split instruction, or
|
cutfun |
function. Function which accepts the full vector of |
cutlabelfun |
function. Function which returns either labels for the
cuts or NULL when passed the return value of |
extra_args |
list. Extra arguments to be passed to the tabulation function. Element position in the list corresponds to the children of this split. Named elements in the child-specific lists are ignored if they do not match a formal argument of the tabulation function. |
child_labels |
string. One of |
indent_mod |
numeric. Modifier for the default indent position for the structure created by this function(subtable, content table, or row) and all of that structure's children. Defaults to 0, which corresponds to the unmodified default behavior. |
For dynamic cuts, the cut is transformed into a static cut by
build_table
based on the full dataset, before
proceeding. Thus even when nested within another split in column/row space,
the resulting split will reflect the overall values (e.g., quartiles) in the
dataset, NOT the values for subset it is nested under.
A PreDataTableLayouts
object suitable for passing to further
layouting functions, and to build_table
.
Gabriel Becker
library(dplyr)
# split_cols_by_cuts
lyt <- basic_table() %>%
split_cols_by("ARM") %>%
split_cols_by_cuts("AGE", split_label = "Age",
cuts = c(0, 25, 35, 1000),
cutlabels = c("young", "medium", "old")) %>%
analyze(c("BMRKR2", "STRATA2")) %>%
append_topleft("counts")
tbl <- build_table(lyt, ex_adsl)
tbl
# split_rows_by_cuts
lyt2 <- basic_table() %>%
split_cols_by("ARM") %>%
split_rows_by_cuts("AGE", split_label = "Age",
cuts = c(0, 25, 35, 1000),
cutlabels = c("young", "medium", "old")) %>%
analyze(c("BMRKR2", "STRATA2")) %>%
append_topleft("counts")
tbl2 <- build_table(lyt2, ex_adsl)
tbl2
# split_cols_by_quartiles
lyt3 <- basic_table() %>%
split_cols_by("ARM") %>%
split_cols_by_quartiles("AGE", split_label = "Age") %>%
analyze(c("BMRKR2", "STRATA2")) %>%
append_topleft("counts")
tbl3 <- build_table(lyt3, ex_adsl)
tbl3
# split_rows_by_quartiles
lyt4 <- basic_table(show_colcounts = TRUE) %>%
split_cols_by("ARM") %>%
split_rows_by_quartiles("AGE", split_label = "Age") %>%
analyze("BMRKR2") %>%
append_topleft(c("Age Quartiles", " Counts BMRKR2"))
tbl4 <- build_table(lyt4, ex_adsl)
tbl4
# split_cols_by_cutfun
cutfun <- function(x) {
cutpoints <- c(
min(x),
mean(x),
max(x)
)
names(cutpoints) <- c("", "Younger", "Older")
cutpoints
}
lyt5 <- basic_table() %>%
split_cols_by_cutfun("AGE", cutfun = cutfun) %>%
analyze("SEX")
tbl5 <- build_table(lyt5, ex_adsl)
tbl5
# split_rows_by_cutfun
lyt6 <- basic_table() %>%
split_cols_by("SEX") %>%
split_rows_by_cutfun("AGE", cutfun = cutfun) %>%
analyze("BMRKR2")
tbl6 <- build_table(lyt6, ex_adsl)
tbl6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.