Create a simple cross-table
tm_t_crosstable.Rd
Create a simple cross-table
Usage
tm_t_crosstable(
label = "Cross Table",
x,
y,
show_percentage = TRUE,
show_total = TRUE,
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args()
)
Arguments
- label
(
character
) Label shown in the navigation item for the module.- x
(
data_extract_spec
orlist
of multipledata_extract_spec
) Object with all available choices with pre-selected option for variable X - row values. In case ofdata_extract_spec
useselect_spec(..., ordered = TRUE)
if table elements should be rendered according to selection order.- y
(
data_extract_spec
orlist
of multipledata_extract_spec
) Object with all available choices with pre-selected option for variable Y - column valuesdata_extract_spec
must not allow multiple selection in this case.- show_percentage
optional, (
logical
) Whether to show percentages (relevant only whenx
is afactor
). Defaults toTRUE
.- show_total
optional, (
logical
) Whether to show total column. Defaults toTRUE
.- pre_output
(
shiny.tag
, optional)
with text placed before the output to put the output into context. For example a title.- post_output
(
shiny.tag
, optional) with text placed after the output to put the output into context. For example theshiny::helpText()
elements are useful.- basic_table_args
-
(
basic_table_args
) object created byteal.widgets::basic_table_args()
with settings for the module table. The argument is merged with options variableteal.basic_table_args
and default module setup.For more details see the vignette:
vignette("custom-basic-table-arguments", package = "teal.widgets")
Note
For more examples, please see the vignette "Using cross table" via
vignette("using-cross-table", package = "teal.modules.general")
.
Examples
# Percentage cross table of variables from ADSL dataset
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"),
check = TRUE
),
modules = modules(
tm_t_crosstable(
label = "Cross Table",
x = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(ADSL, subset = function(data) {
idx <- !vapply(data, inherits, logical(1), c("Date", "POSIXct", "POSIXlt"))
return(names(data)[idx])
}),
selected = "COUNTRY",
multiple = TRUE,
ordered = TRUE,
fixed = FALSE
)
),
y = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(ADSL, subset = function(data) {
idx <- vapply(data, is.factor, logical(1))
return(names(data)[idx])
}),
selected = "SEX",
multiple = FALSE,
fixed = FALSE
)
),
basic_table_args = teal.widgets::basic_table_args(subtitles = "Table generated by Crosstable Module")
)
)
)
#> [INFO] 2022-06-14 17:42:51.2477 pid:1110 token:[] teal.modules.general Initializing tm_t_crosstable
if (FALSE) {
shinyApp(app$ui, app$server)
}