View source: R/tt_dotabulation.R
qtable_layout | R Documentation |
This function provides a convenience interface for generating generalizations of a 2-way frequency table. Row and column space can be facetted by variables, and an analysis function can be specified. The function then builds a layout with the specified layout and applies it to the data provided.
qtable_layout(
data,
row_vars = character(),
col_vars = character(),
avar = NULL,
row_labels = NULL,
afun = NULL,
summarize_groups = FALSE,
title = "",
subtitles = character(),
main_footer = character(),
prov_footer = character(),
show_colcounts = TRUE,
drop_levels = TRUE,
...,
.default_rlabel = NULL
)
qtable(
data,
row_vars = character(),
col_vars = character(),
avar = NULL,
row_labels = NULL,
afun = NULL,
summarize_groups = FALSE,
title = "",
subtitles = character(),
main_footer = character(),
prov_footer = character(),
show_colcounts = TRUE,
drop_levels = TRUE,
...
)
data |
( |
row_vars |
( |
col_vars |
( |
avar |
( |
row_labels |
( |
afun |
( |
summarize_groups |
( |
title |
( |
subtitles |
( |
main_footer |
( |
prov_footer |
( |
show_colcounts |
( |
drop_levels |
( |
... |
additional arguments passed to |
.default_rlabel |
( |
This function creates a table with a single top-level structure in both row and column dimensions involving faceting by 0 or more variables in each dimension.
The display of the table depends on certain details of the tabulation. In the case of an afun
which returns a
single cell's contents (either a scalar or a vector of 2 or 3 elements), the label rows for the deepest-nested row
facets will be hidden and the labels used there will be used as the analysis row labels. In the case of an afun
which returns a list (corresponding to multiple cells), the names of the list will be used as the analysis row
labels and the deepest-nested facet row labels will be visible.
The table will be annotated in the top-left area with an informative label displaying the analysis variable
(avar
), if set, and the function used (captured via substitute) where possible, or 'count' if not. One exception
where the user may directly modify the top-left area (via row_labels
) is the case of a table with row facets and
an afun
which returns a single row.
qtable
returns a built TableTree
object representing the desired table
qtable_layout
returns a PreDataTableLayouts
object declaring the structure of the desired table, suitable for
passing to build_table()
.
qtable(ex_adsl)
qtable(ex_adsl, row_vars = "ARM")
qtable(ex_adsl, col_vars = "ARM")
qtable(ex_adsl, row_vars = "SEX", col_vars = "ARM")
qtable(ex_adsl, row_vars = c("COUNTRY", "SEX"), col_vars = c("ARM", "STRATA1"))
qtable(ex_adsl,
row_vars = c("COUNTRY", "SEX"),
col_vars = c("ARM", "STRATA1"), avar = "AGE", afun = mean
)
summary_list <- function(x, ...) as.list(summary(x))
qtable(ex_adsl, row_vars = "SEX", col_vars = "ARM", avar = "AGE", afun = summary_list)
suppressWarnings(qtable(ex_adsl,
row_vars = "SEX",
col_vars = "ARM", avar = "AGE", afun = range
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.