1

我使用 RStudio 创建了一个基本的 Shiny 应用程序。我正在使用 selectInput 过滤仪表板上的图表。我创建的图表之一工作正常,并且在应用程序加载时保留默认选择。但是,对于我的另一个图表,指定的默认值会在加载时短暂出现,但随后会消失并使图表和 selectInput 都为空,直到手动选择过滤器。

    fluidRow(
        column(6,
            sidebarPanel(
                selectInput("indication",
                            "Indication:",
                            choices = data1$indication,
                            selected = 1))),
        column(6,
               sidebarPanel(
                   selectInput("Practice_Id",
                               "Practice ID:",
                               choices = data2$Practice_Id,
                               selected = 1)))
# relevant output below

    output$riskBarPlot <- renderPlotly({

        risk_bar_filt <- risk_bar_data %>%
            filter(Practice_Id == input$Practice_Id)

        risk_bar <- ggplot(risk_bar_filt, aes(x = Indication, y = Brier_Score)) +
            geom_bar(aes(fill = Brier_Score, stat= "identity") +
        ggplotly(risk_bar, tooltip = c("x", "y"))
    })

这是此示例中的第二个输入无法正常工作,我刚刚包含第一个以表明它可以正常工作并且它们之间没有重大差异。我也尝试将其更改为 [selected = "我希望默认选择的值"] 但这并没有修复错误。

加载后的仪表板图像:

加载后的仪表板屏幕截图

非常感谢您在应用程序加载时显示默认选择的任何帮助!

4

0 回答 0