Distribution Module
tm_g_distribution.RdDistribution Module
Usage
tm_g_distribution(
label = "Distribution Module",
dist_var,
strata_var = NULL,
group_var = NULL,
freq = FALSE,
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void",
"test"),
ggplot2_args = teal.widgets::ggplot2_args(),
bins = c(30L, 1L, 100L),
plot_height = c(600, 200, 2000),
plot_width = NULL,
pre_output = NULL,
post_output = NULL
)Arguments
- label
(
character(1)) Label shown in the navigation item for the module. Any label possible except"global_filters"- read more inmappingargument of teal_slices.- dist_var
(
data_extract_specorlistof multipledata_extract_spec) Variable to consider for the distribution analysis.- strata_var
(
data_extract_specorlistof multipledata_extract_spec) Categorical variable to split the selected distribution variable on.- group_var
optional, (
data_extract_specorlistof multipledata_extract_spec) Which data columns to use for faceting rows.- freq
optional, (
logical) Whether to display frequency (TRUE) or density (FALSE). Defaults to density (FALSE).- ggtheme
optional, (
character)ggplot2theme to be used by default. One ofc("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void", "test"). Each theme can be chosen by the user during the session. Defaults to"gray".- ggplot2_args
-
optional, (
ggplot2_args) object created byteal.widgets::ggplot2_args()with settings for all the plots or named list ofggplot2_argsobjects for plot-specific settings. The argument is merged with options variableteal.ggplot2_argsand default module setup.List names should match the following:
c("default", "Histogram", "QQplot").For more details see the vignette:
vignette("custom-ggplot2-arguments", package = "teal.widgets"). - bins
optional, (
integer(1)orinteger(3)) If scalar then the histogram bins will have a fixed size. If a slider should be presented to adjust the number of histogram bins dynamically then it can be a vector of length three withc(value, min, max). Defaults toc(30L, 1L, 100L).- plot_height
optional, (
numeric) A vector of length three withc(value, min and max)for a slider encoding the plot height.- plot_width
optional, (
numeric) A vector of length three withc(value, min and max)for a slider encoding the plot width.- 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.
Examples
# Example with non-clinical data
app <- teal::init(
data = teal_data(dataset("iris", iris)),
modules = list(
teal.modules.general::tm_g_distribution(
dist_var = teal.transform::data_extract_spec(
dataname = "iris",
select = teal.transform::select_spec(variable_choices("iris"), "Petal.Length")
),
ggplot2_args = teal.widgets::ggplot2_args(
labs = list(subtitle = "Plot generated by Distribution Module")
)
)
)
)
#> [INFO] 2023-08-14 13:51:35.5444 pid:1296 token:[] teal.modules.general Initializing tm_g_distribution
#> Registered S3 method overwritten by 'ggpmisc':
#> method from
#> as.character.polynomial polynom
if (interactive()) {
shinyApp(app$ui, app$server)
}
# Example with clinical data
ADSL <- teal.modules.general::rADSL
vars1 <- choices_selected(variable_choices(ADSL, c("ARM", "COUNTRY", "SEX")), selected = NULL)
app <- teal::init(
data = teal.data::cdisc_data(
teal.data::cdisc_dataset("ADSL", ADSL),
code = "ADSL <- teal.modules.general::rADSL",
check = FALSE
),
modules = teal::modules(
teal.modules.general::tm_g_distribution(
dist_var = teal.transform::data_extract_spec(
dataname = "ADSL",
select = teal.transform::select_spec(
choices = teal.transform::variable_choices(ADSL, c("AGE", "BMRKR1")),
selected = "BMRKR1",
multiple = FALSE,
fixed = FALSE
)
),
strata_var = teal.transform::data_extract_spec(
dataname = "ADSL",
filter = teal.transform::filter_spec(
vars = vars1,
multiple = TRUE
)
),
group_var = teal.transform::data_extract_spec(
dataname = "ADSL",
filter = teal.transform::filter_spec(
vars = vars1,
multiple = TRUE
)
),
ggplot2_args = teal.widgets::ggplot2_args(
labs = list(subtitle = "Plot generated by Distribution Module")
)
)
)
)
#> [INFO] 2023-08-14 13:51:36.0748 pid:1296 token:[] teal.modules.general Initializing tm_g_distribution
if (interactive()) {
shinyApp(app$ui, app$server)
}