R Language Shiny Radio Button


Example

You can create a set of radio buttons used to select an item from a list.

It's possible to change the settings :

  • selected : The initially selected value (character(0) for no selection)
  • inline : horizontal or vertical
  • width

It is also possible to add HTML.

library(shiny)

ui <- fluidPage(    
  radioButtons("radio", 
               label = HTML('<FONT color="red"><FONT size="5pt">Welcome</FONT></FONT><br> <b>Your favorite color is red ?</b>'),
               choices = list("TRUE" = 1, "FALSE" = 2),
               selected = 1,
               inline = T,
               width = "100%"),      
  fluidRow(column(3, textOutput("value")))) 


server <- function(input, output){
  output$value <- renderPrint({
    if(input$radio == 1){return('Great !')}
     else{return("Sorry !")}})}

shinyApp(ui = ui, server = server)

enter image description here