updateAwesomeRadio: Change the value of a radio input on the client

Description Usage Arguments See Also Examples

Description

Change the value of a radio input on the client

Usage

1
2
3
updateAwesomeRadio(session, inputId, label = NULL, choices = NULL,
  selected = NULL, inline = FALSE, status = "primary",
  checkbox = FALSE)

Arguments

session

The session object passed to function given to shinyServer.

inputId

The id of the input object.

label

Input label.

choices

List of values to select from (if elements of the list are named then that name rather than the value is displayed to the user)

selected

The initially selected value

inline

If TRUE, render the choices inline (i.e. horizontally)

status

Color of the buttons

checkbox

Checkbox style

See Also

awesomeRadio

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## Not run: 

if (interactive()) {

library("shiny")
library("shinyWidgets")


ui <- fluidPage(
  awesomeRadio(
    inputId = "somevalue",
    choices = c("A", "B", "C"),
    label = "My label"
  ),

  verbatimTextOutput(outputId = "res"),

  actionButton(inputId = "updatechoices", label = "Random choices"),
  textInput(inputId = "updatelabel", label = "Update label")
)

server <- function(input, output, session) {

  output$res <- renderPrint({
    input$somevalue
  })

  observeEvent(input$updatechoices, {
    updateAwesomeRadio(
      session = session, inputId = "somevalue",
      choices = sample(letters, sample(2:6))
    )
  })

  observeEvent(input$updatelabel, {
    updateAwesomeRadio(
      session = session, inputId = "somevalue",
      label = input$updatelabel
    )
  }, ignoreInit = TRUE)

}

shinyApp(ui = ui, server = server)

}


## End(Not run)

dreamRs/shinyWidgets documentation built on June 5, 2019, 4:07 a.m.