單選按鈕
你可以建立一組用於從列表中選擇專案的單選按鈕。
可以更改設定:
- selected:最初選擇的值(沒有選擇的字元(0))
- 內聯:水平或垂直
- 寬度
也可以新增 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)
