执行时脚本会在下面创建一个红色圆圈图标和一个反应散点图。我已经制作了脚本,在选择“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)