R闪亮的反应曲线并选择默认

时间:2020-03-26 19:27:59

标签: r shiny

更新:问题2已回答。谢谢@Ben!只是寻求有关Q1的帮助并进行选择。

我所拥有的:使用selectize用户可以搜索退休金计划。 问题1:如何避免采用默认计划,而只需要“在此处输入...”?

我想要的是:尽管计划选择工作正常,但是我试图绘制选择计划时计划成员的年龄。 问题2:如何使我的输出(年龄)对输入(计划名称)有反应?

我的 ui.r

fluidPage(    

  titlePanel("Atlantis Pension Dashboard"),
  sidebarLayout(      
    sidebarPanel(
      #Dynamic select type
      selectizeInput('Plan_Name', 'Search plan by keyword', choices = unique(Active$Plan_Name)),
      multiple = TRUE,

      #Static drop down
      selectInput('Plan_Name', "All plans", 
                  choices=unique(Active$Plan_Name)),
      hr(),
      helpText("Data from...")
    ),

    # Spot for hist
    mainPanel(
      plotOutput("agePlot")  
    )))

和我的 server.r

function(input, output) {

  Plan <- reactive(input$Plan_Name)

  # Dynamic plan select
  output$Plan_Name <- renderPrint({
    str(sapply(sprintf('Plan_Name'), function(id) {
      input[[id]]
    }, simplify = FALSE))
  })

  # Age histogram dependant on the chosed plan
  output$agePlot <- renderPlot({
    req(Plan())
    hist(Active[Plan()]$age)
  }

  )
}

我尝试过的事情:该死的东西都在附近(愚蠢无助)。

enter image description here

0 个答案:

没有答案
相关问题