R Shiny - 多个反应子集/滑块

时间:2017-01-11 21:15:39

标签: r shiny

我有一个闪亮的仪表板,我试图创建多个滑块,根据数据框中的不同列对数据进行子集化。

我有日期滑块工作,但我试图通过(0,1)之间的连续分数向量过滤的滑块不起作用....我应该如何解决这个问题?

HireDate过滤器单独工作,当我按“daterange [1]”和daterange [2]过滤....是[1]和[2]命令将输入​​范围链接到我的开始和结束日期在ui.R部分代码?

以下代码:

server.R

shinyServer(function(input, output) {


  output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x    <- reactive({subset(DATA, HireDate >= input$daterange[1] & 
                           HireDate <= input$daterange[2] & Value >= input$scorecalc[1]   & Value >= input$scorecalc[1] <= input$scorecalc[2]) })
dd <- x()


bins <- seq(0, 1, length.out = input$bins + 1)


hist(dd$ResumeScore, breaks = bins)

# hist(dd$Value, breaks = bins, col = 'darkgray', border = 'white') # 
})
})

ui.R

library(shiny)
shinyUI(pageWithSidebar(
  # Application title
  headerPanel("Dashboard"),
  sidebarPanel( 
    sliderInput("bins",
                "Number of bins:",
                min = 1,
                max = 50,
                value = 30),

    sliderInput("scorecalc",
                "Score:",
                min = 0,
                max = 1,
                            value = 0),


    dateRangeInput("daterange", "Date range:",
                   start  = "2016-08-01",
                   end    = "2016-12-31",
                   min    = "2016-08-01",
                   max    = "2016-12-31",
                   format = "yyyy/mm/dd",
                   separator = "-"),

    submitButton(text="Update!")


    ),
     # OUTPUT PART
    mainPanel(
      tabsetPanel(
      tabPanel("Tab 1", h4("Global Histogram"),plotOutput("distPlot"))

     )
     )
     )) 

0 个答案:

没有答案