title: How to select rows of a matrix which has to meet mutiple conditions in R Shiny
body: <p>The goal is to build an application able to select and present only rows of a matrix that meets specific conditions selected by the user via Shiny elements such as <code>checkboxes</code> and <code>sliderInput</code>
  Our <code>data</code> is subject to two (or more) ways to be filtered:</p>
  
  <ol>
  <li>Via <code>checkboxGroupInput</code> where user can select one or more numbers</li>
  <li>Via <code>sliders</code>. There will be one slider for each column of <code>data</code>. This allows user to select the range of numbers for each column.</li>
  </ol>
  
  <p>I got stuck on making the <code>data</code> react to the selection entered by the user. Any suggestion is appreciated!</p>
  
  <p>Here is the code that I have:</p>
  
  <h3>server.R</h3>
  
  <pre><code>   # Load libraries.
     library(shiny)
     library(datasets)
     library(xtable)
     library(R.utils)
  
   shinyServer(
       function(input, output) {
        source('global.R', local=TRUE)
  
  getDataName &lt;- reactive({
    out &lt;- input$dataName
    print(out)
    return(out)
  })
  
  getData &lt;- reactive({
      cat("Getting data for, ", getDataName(), ".", sep = '')
    if(getDataName() == ""){
        print("ERROR: getDAtaName is empty! Check your code!")
        out &lt;- NULL
    }
    else {
        dataSet &lt;- t(combn(max(selectRange(getDataName())), numCols(getDataName())))
  
    }
    print(head(dataSet, n = 10))
    return(dataSet)
  })
  
  
  selectedValues &lt;- reactive({
    print("Numbers selected via checkboxes:")
    print(input$numSelector)
  })      
  
  output$numSelector &lt;- renderUI({
    out &lt;- checkboxGroupInput(
      inputId = "numSelector",
      label   = "Select the numbers to be included in the rows",
      choices = selectRange(input$dataName),  
      inline = TRUE
    )
    return(out)
  })
  
  output$sliders &lt;- renderUI({
    numSliders &lt;- numCols(input$dataName)
    lapply(1:numSliders, function(i) {
      sliderInput(
        inputId = paste0('column', i),
        label = paste0('Select the range for column ', i),
        min = min(selectRange(input$dataName)),
        max = max(selectRange(input$dataName)),
        value = c(min(selectRange(input$dataName)), max(selectRange(input$dataName))),
        step =1)
    })
  })
  
  
  
  output$selectedDataDisplay &lt;- renderDataTable({
    as.table(getData())}, options = list(lengthMenu = c(5, 30, 50), pageLength = 10))
  }
  </code></pre>
  
  <p>)</p>
  
  <h3>ui.R</h3>
  
  <pre><code>library(shiny)
  
   shinyUI(
      pageWithSidebar(
         headerPanel("Selection zone"),
  
  # Select inputs
  sidebarPanel(
  
    selectInput(
      inputId = "dataName",
      label   = "Select data",
      choices = c("data1", "data2", "data3", "data4")
    ),
  
  
    uiOutput(outputId = "numSelector"),
    uiOutput(outputId = "sliders")
  
  ),
  
  mainPanel(
     tableOutput("selectedDataDisplay"))
  
   )
  )
  </code></pre>
  
  <h3>global.R</h3>
  
  <pre><code> selectRange &lt;- function(x){
   if(x == "data1"){choices = c(1:10)}
   if(x == "data2"){choices = c(1:15)}
   if(x == "data3"){choices = c(1:20)}
   if(x == "data4"){choices = c(1:25)}
   return(choices)
  }
  
  numCols &lt;- function(x){
   if(x == "data1"){maxNum = 10
                 numCol = 5}
   if(x == "data2"){maxNum = 15
                 numCol = 5}
   if(x == "data3"){maxNum = 20 
                numCol = 5}
   if(x == "data4"){maxNum = 25 
                numCol = 6}
   return(numCol)
   }
  </code></pre>