【发布时间】:2020-08-05 13:49:39
【问题描述】:
我对 R 很陌生,所以这可能非常明显,但我真的被卡住了!
我已经创建了五个现有的绘图图表。我希望能够从下拉列表中以闪亮的方式选择它们。我无法使现有图表名称和下拉菜单之间的链接起作用。
我最近的尝试(不起作用):
ui <-shinyUI(fluidPage(selectInput("selectPlot", "Select Year:",
choices = c("2015", "2016", "2017", "2018", "Average price across US"),
selected = "Average price across US", plotlyOutput("plot"))))
server <- shinyServer(function(input,output){
output$plot <- renderPlotly({
if(input$selectPlot == '2015') {
p <- gg1
}
if(input$selectPlot == '2016') {
p <- gg2
}
if(input$selectPlot == '2017') {
p <- gg3
}
if(input$selectPlot == '2018') {
p <- gg4
}
if(input$selectPlot == 'Average price across US') {
p <- gg5
}
return(p)
})
})
shinyApp(ui,server)
我试图让 gg1 显示何时选择“2015”等。
【问题讨论】: