Distribution Module
tm_g_distribution.Rd
Distribution 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
) Label shown in the navigation item for the module.- dist_var
(
data_extract_spec
orlist
of multipledata_extract_spec
) Variable to consider for the distribution analysis.- strata_var
(
data_extract_spec
orlist
of multipledata_extract_spec
) Categorical variable to split the selected distribution variable on.- group_var
optional, (
data_extract_spec
orlist
of 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
)ggplot2
theme 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_args
objects for plot-specific settings. The argument is merged with options variableteal.ggplot2_args
and 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 <- init(
data = teal_data(dataset("iris", iris)),
modules = list(
tm_g_distribution(
dist_var = data_extract_spec(
dataname = "iris",
select = select_spec(variable_choices("iris"), "Petal.Length")
),
ggplot2_args = teal.widgets::ggplot2_args(labs = list(subtitle = "Plot generated by Distribution Module"))
)
)
)
#> [INFO] 2022-06-14 17:42:32.1896 pid:1110 token:[] teal.modules.general Initializing tm_g_distribution
if (FALSE) {
shinyApp(app$ui, app$server)
}
# Example with clinical data
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl
vars1 <- choices_selected(variable_choices(ADSL, c("ARM", "COUNTRY", "SEX")), selected = NULL)
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL),
code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl",
check = FALSE
),
modules = modules(
tm_g_distribution(
dist_var = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(ADSL, c("AGE", "BMRKR1")),
selected = "BMRKR1",
multiple = FALSE,
fixed = FALSE
)
),
strata_var = data_extract_spec(
dataname = "ADSL",
filter = filter_spec(
vars = vars1,
multiple = TRUE
)
),
group_var = data_extract_spec(
dataname = "ADSL",
filter = filter_spec(
vars = vars1,
multiple = TRUE
)
),
ggplot2_args = teal.widgets::ggplot2_args(labs = list(subtitle = "Plot generated by Distribution Module"))
)
)
)
#> [INFO] 2022-06-14 17:42:33.2233 pid:1110 token:[] teal.modules.general Initializing tm_g_distribution
if (FALSE) {
shinyApp(app$ui, app$server)
}