0

该脚本在执行时会在下方创建一个红色圆圈图标和一个反应散点图。我已经制作了这样的脚本,以便在选择“A”、“B”、“C”选项时,我们能够动态更新情节。但是,单击红色圆圈,我只是看到下拉列表中的第一个选项。我想查看此下拉列表中的所有选项。我会为你附上截图。

## app.R ##
library(shiny)
library(shinydashboard)
library(shinyWidgets)

ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
),
dashboardBody(
dropdownButton(
pickerInput(inputId = "statnames", 
              label = "", 
              choices = c("A", 
                          "B", 
                          "C", 
                          "D", 
                          "E", 
                          "F"), 
              choicesOpt = list(icon = c("glyphicon glyphicon-arrow-right", 
                                         "glyphicon glyphicon-cog", 
                                         "glyphicon glyphicon-play", 
                                         "glyphicon glyphicon-ok-sign", 
                                         "glyphicon glyphicon-euro", 
                                         "glyphicon glyphicon-music")), 
              options = list(`icon-base` = "")),
  circle = TRUE, status = "danger", icon = icon("gear"), width = "300px",
  tooltip = tooltipOptions(title = "Click to see inputs !")),
  plotOutput("state")
  )
  )
server <- function(input, output) 
{
output$state = renderPlot(
if(input$statnames == "A")
 plot(iris$Sepal.Length)
else
 if(input$statnames == "B")
   plot(iris$Sepal.Width)
else
 if(input$statnames == "C")
   plot(iris$Petal.Width)
else
 if(input$statnames == "D")
   plot(iris$Petal.Length)
else
 if(input$statnames == "E")
   plot(iris$Sepal.Width)
else
 if(input$statnames == "F")
   plot(iris$Sepal.Length)
else
 return()
 )
 }
 shinyApp(ui, server)

4

0 回答 0