Response Plots
tm_g_response.RdResponse Plots
Usage
tm_g_response(
label = "Response Plot",
response,
x,
row_facet = NULL,
col_facet = NULL,
coord_flip = FALSE,
count_labels = TRUE,
rotate_xaxis_labels = FALSE,
freq = FALSE,
plot_height = c(600, 400, 5000),
plot_width = NULL,
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void",
"test"),
ggplot2_args = teal.widgets::ggplot2_args(),
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.- response
(
data_extract_specorlistof multipledata_extract_spec) Which variable to use as the response. You can define one fixed column by using the settingfixed = TRUEinside theselect_spec.data_extract_specmust not allow multiple selection in this case.- x
(
data_extract_specorlistof multipledata_extract_spec) Which variable to use on the X-axis of the response plot. Allow the user to select multiple columns from thedataallowed in teal.data_extract_specmust not allow multiple selection in this case.- row_facet
optional, (
data_extract_specorlistof multipledata_extract_spec) Which data columns to use for faceting rows.- col_facet
optional, (
data_extract_specorlistof multipledata_extract_spec) Which data to use for faceting columns.- coord_flip
optional, (
logical) Whether to flip coordinates betweenxandresponse.- count_labels
optional, (
logical) Whether to show count labels. Defaults toTRUE.- rotate_xaxis_labels
optional, (
logical) Whether to rotate plot X axis labels. Does not rotate by default (FALSE).- freq
optional, (
logical) Whether to display frequency (TRUE) or density (FALSE). Defaults to density (FALSE).- 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.- 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
-
(
ggplot2_args) object created byteal.widgets::ggplot2_args()with settings for the module plot. The argument is merged with options variableteal.ggplot2_argsand default module setup.For more details see the vignette:
vignette("custom-ggplot2-arguments", package = "teal.widgets") - 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.
Note
For more examples, please see the vignette "Using response plot" via
vignette("using-response-plot", package = "teal.modules.general").
Examples
# Response plot with selected response (BMRKR1) and selected x variable (RACE)
library(nestcolor)
ADSL <- teal.modules.general::rADSL
app <- teal::init(
data = teal.data::cdisc_data(
teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"),
check = TRUE
),
modules = teal::modules(
teal.modules.general::tm_g_response(
label = "Response Plots",
response = teal.transform::data_extract_spec(
dataname = "ADSL",
select = teal.transform::select_spec(
label = "Select variable:",
choices = teal.transform::variable_choices(ADSL, c("BMRKR2", "COUNTRY")),
selected = "BMRKR2",
multiple = FALSE,
fixed = FALSE
)
),
x = teal.transform::data_extract_spec(
dataname = "ADSL",
select = teal.transform::select_spec(
label = "Select variable:",
choices = teal.transform::variable_choices(ADSL, c("SEX", "RACE")),
selected = "RACE",
multiple = FALSE,
fixed = FALSE
)
),
ggplot2_args = teal.widgets::ggplot2_args(
labs = list(subtitle = "Plot generated by Response Module")
)
)
)
)
#> [INFO] 2023-08-14 13:51:36.7354 pid:1296 token:[] teal.modules.general Initializing tm_g_response
if (interactive()) {
shinyApp(app$ui, app$server)
}