Hide, Show Label only or display a pickerInput
optionalSelectInput.Rd
Hidden input widgets are useful to have the input[[inputId]]
variable
on available in the server function but no corresponding visual clutter from
input widgets that provide only a single choice.
Usage
optionalSelectInput(
inputId,
label = NULL,
choices = NULL,
selected = NULL,
multiple = FALSE,
sep = NULL,
options = list(),
label_help = NULL,
fixed = FALSE,
width = NULL
)
Arguments
- inputId
The
input
slot that will be used to access the value.- label
Display label for the control, or
NULL
for no label.- choices
(
character
,NULL
)
Ifchoices
isNULL
nopickerInput
widget is displayed andinput[[inputId]]
will be""
. Ifchoices
is of length 1 then a label and character string will be displayed and thepickerInput
widget will be hidden. If the length ofchoices
is more than one thepickerInput
element will be displayed. If elements of the list are named then that name rather than the value is displayed to the user.- selected
The initially selected value (or multiple values if
multiple = TRUE
). If not specified then defaults to the first value for single-select lists and no values for multiple select lists.- multiple
Is selection of multiple items allowed?
- sep
(
character(1)
)
A separator string to split thechoices
orselected
inputs into the values of the different columns.- options
List of options, see pickerOptions for all available options. To limit the number of selection possible, see example below.
- label_help
(
shiny.tag
optional)
e.g. an object returned byshiny::helpText()
.- fixed
(
logical(1)
optional)
whether to block user to select choices.- width
(
character(1)
)
The width of the input passed topickerInput
e.g.'auto'
,'fit'
,'100px'
or'75%'
Examples
if (FALSE) {
optionalSelectInput(inputId = "xvar", label = "x variable", choices = "A", selected = "A")
optionalSelectInput(
inputId = "xvar",
label = "x variable",
choices = LETTERS[1:5],
selected = "A"
)
optionalSelectInput(
inputId = "xvar",
label = "x variable",
choices = c("A - value A" = "A"),
selected = "A"
)
ADRS <- scda::synthetic_cdisc_data("latest")$adrs # nolint
optionalSelectInput(
inputId = "xvar",
label = "x variable",
choices = teal.transform::variable_choices(data = ADRS, subset = c("AGE", "SEX", "PARAMCD")),
selected = "PARAMCD"
)
selected_value <- paste0(lapply(ADRS[1, c("PARAMCD", "AVISIT")], as.character), collapse = " - ")
optionalSelectInput(
inputId = "xvar",
label = "x variable",
choices = teal.transform::value_choices(
data = ADRS,
var_choices = c("PARAMCD", "AVISIT"),
var_label = c("PARAM", "AVISIT")
),
selected = selected_value
)
}