| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/update-input.R |
| 3 |
\name{updateRadioButtons} |
| 4 |
\alias{updateRadioButtons} |
| 5 |
\title{Change the value of a radio input on the client} |
| 6 |
\usage{ |
| 7 |
updateRadioButtons( |
| 8 |
session = getDefaultReactiveDomain(), |
| 9 |
inputId, |
| 10 |
label = NULL, |
| 11 |
choices = NULL, |
| 12 |
selected = NULL, |
| 13 |
inline = FALSE, |
| 14 |
choiceNames = NULL, |
| 15 |
choiceValues = NULL |
| 16 |
) |
| 17 |
} |
| 18 |
\arguments{ |
| 19 |
\item{session}{The \code{session} object passed to function given to |
| 20 |
\code{shinyServer}. Default is \code{getDefaultReactiveDomain()}.} |
| 21 |
|
| 22 |
\item{inputId}{The id of the input object.} |
| 23 |
|
| 24 |
\item{label}{The label to set for the input object.} |
| 25 |
|
| 26 |
\item{choices}{List of values to select from (if elements of the list are |
| 27 |
named then that name rather than the value is displayed to the user). If |
| 28 |
this argument is provided, then \code{choiceNames} and \code{choiceValues} must not |
| 29 |
be provided, and vice-versa. The values should be strings; other types |
| 30 |
(such as logicals and numbers) will be coerced to strings.} |
| 31 |
|
| 32 |
\item{selected}{The initially selected value. If not specified, then it |
| 33 |
defaults to the first item in \code{choices}. To start with no items selected, |
| 34 |
use \code{character(0)}.} |
| 35 |
|
| 36 |
\item{inline}{If \code{TRUE}, render the choices inline (i.e. horizontally)} |
| 37 |
|
| 38 |
\item{choiceNames, choiceValues}{List of names and values, respectively, that |
| 39 |
are displayed to the user in the app and correspond to the each choice (for |
| 40 |
this reason, \code{choiceNames} and \code{choiceValues} must have the same length). |
| 41 |
If either of these arguments is provided, then the other \emph{must} be provided |
| 42 |
and \code{choices} \emph{must not} be provided. The advantage of using both of these |
| 43 |
over a named list for \code{choices} is that \code{choiceNames} allows any type of UI |
| 44 |
object to be passed through (tag objects, icons, HTML code, ...), instead |
| 45 |
of just simple text. See Examples.} |
| 46 |
} |
| 47 |
\description{ |
| 48 |
Change the value of a radio input on the client |
| 49 |
} |
| 50 |
\details{ |
| 51 |
The input updater functions send a message to the client, telling it to |
| 52 |
change the settings of an input object. The messages are collected and sent |
| 53 |
after all the observers (including outputs) have finished running. |
| 54 |
|
| 55 |
The syntax of these functions is similar to the functions that created the |
| 56 |
inputs in the first place. For example, \code{\link{numericInput}()} and |
| 57 |
\code{updateNumericInput()} take a similar set of arguments. |
| 58 |
|
| 59 |
Any arguments with NULL values will be ignored; they will not result in any |
| 60 |
changes to the input object on the client. |
| 61 |
|
| 62 |
For \code{\link{radioButtons}()}, \code{\link{checkboxGroupInput}()} and |
| 63 |
\code{\link{selectInput}()}, the set of choices can be cleared by using |
| 64 |
\code{choices=character(0)}. Similarly, for these inputs, the selected item |
| 65 |
can be cleared by using \code{selected=character(0)}. |
| 66 |
} |
| 67 |
\examples{ |
| 68 |
## Only run examples in interactive R sessions |
| 69 |
if (interactive()) { |
| 70 |
|
| 71 |
ui <- fluidPage( |
| 72 |
p("The first radio button group controls the second"), |
| 73 |
radioButtons("inRadioButtons", "Input radio buttons", |
| 74 |
c("Item A", "Item B", "Item C")), |
| 75 |
radioButtons("inRadioButtons2", "Input radio buttons 2", |
| 76 |
c("Item A", "Item B", "Item C")) |
| 77 |
) |
| 78 |
|
| 79 |
server <- function(input, output, session) { |
| 80 |
observe({ |
| 81 |
x <- input$inRadioButtons |
| 82 |
|
| 83 |
# Can also set the label and select items |
| 84 |
updateRadioButtons(session, "inRadioButtons2", |
| 85 |
label = paste("radioButtons label", x), |
| 86 |
choices = x, |
| 87 |
selected = x |
| 88 |
) |
| 89 |
}) |
| 90 |
} |
| 91 |
|
| 92 |
shinyApp(ui, server) |
| 93 |
} |
| 94 |
} |
| 95 |
\seealso{ |
| 96 |
\code{\link[=radioButtons]{radioButtons()}} |
| 97 |
} |