复选框闪亮

时间:2015-04-22 13:12:58

标签: r shiny

无论如何,我可以允许复选框组至少有一个选择吗?

我希望向量至少有一个选择而不是null。如果此复选框不支持,是否可以更改输入元素 的 UI.R

library(shiny)

# Define UI for miles per gallon application
shinyUI(pageWithSidebar(

  # Application title
  titlePanel("Demo Assignment for SHINY Coursera"),

  # Sidebar with checkbox to select the variable to plot against mpg
  # and to specify whether outliers should be included
  sidebarPanel(



    selectInput("variable1", "Performance Variable:",
                list("MPG" = "mpg", 
                     "qsec" = "qsec")),

    checkboxGroupInput("variable", "Variable:",
                       c("Cylinders" = "cyl", 
                         "Displacement" = "disp", 
                         "HP" = "hp", 
                         "Rear Axle Ratio" = "drat", 
                         "Weight" = "wt", 
                         "Transmission" = "am", 
                         "Carburetors" = "carb", 
                         "Gears" = "gear"), selected = "cyl")


  ),

  # Show the caption and plot of the requested variable against mpg
  mainPanel(

    h4(textOutput("Var_1")),
    h4(textOutput("Var_2")),
    h4(textOutput("caption")),

    h4("Analysis:"),

    plotOutput("mpgPlot")
  )
))

0 个答案:

没有答案