title: R Shiny - Error Subsetting data
body: <p>I am very new to shiny and I am trying to subset a data based on a variable strata after having read the file in CSV. I am constantly getting the error "object of type 'closure' is not subsettable". I would appreciate any help. Thank you.</p>
  
  <p>The code is:</p>
  
  <pre><code>library(shiny)
  library(ggplot2)
  library(dplyr)
  library(tidyverse)
  
  
  ## Only run examples in interactive R sessions
  if (interactive()) {
  
  ui &lt;- fluidPage(
  
  # App title ----
  titlePanel("Uploading Files"),
  
  # Sidebar layout with input and output definitions ----
  sidebarLayout(
  
    # Sidebar panel for inputs ----
    sidebarPanel(
  
      # Input: Select a file ----
      fileInput("file1", "Choose CSV File",
                multiple = TRUE,
                accept = c("text/csv",
                           "text/comma-separated-values,text/plain",
                           ".csv")),
  
      # Horizontal line ----
      tags$hr(),
  
      # Input: Checkbox if file has header ----
      checkboxInput("header", "Header", TRUE),
  
      # Input: Select separator ----
      radioButtons("sep", "Separator",
                   choices = c(Comma = ",",
                               Semicolon = ";",
                               Tab = "\t"),
                   selected = ","),
  
      # Input: Select quotes ----
      radioButtons("quote", "Quote",
                   choices = c(None = "",
                               "Double Quote" = '"',
                               "Single Quote" = "'"),
                   selected = '"'),
  
      # Horizontal line ----
      tags$hr(),
  
      # Input: Select number of rows to display ----
      radioButtons("disp", "Display",
                   choices = c(Head = "head",
                               All = "all"),
                   selected = "head"),
  
  
  
  # Include a Slider for Strata
    sliderInput("strata",
                "strata:",
                min = 1,
                max = 20,
                value = c(1,20),
                step=1)
  
    ),  
  
  ########################## 
  
    # Main panel for displaying outputs ----
    mainPanel(
  
      # Output: Data file ----
      tableOutput("contents")
  
    )  
   )
  )
  
  ###
  
  
  server &lt;- function(input, output, session) {
  
  output$contents &lt;- renderTable({
  
  
  
    req(input$file1)
  
    df &lt;- read.csv(input$file1$datapath,
                   header = input$header,
                   sep = input$sep,
                   quote = input$quote, stringsAsFactors = FALSE)
  
  df&lt;-data.frame(df)
  
    filtered&lt;-reactive({
                    df()%&gt;% 
           filter(df$strata&gt;=input$strata[1] &amp;          df$strata&lt;=input$strata[2])})
  
  
  
    if(input$disp == "head") {
      return(head(filtered))
    }
    else {
      return(filtered)
    }
  
  
  
      })
  
    }
    # Run the app ----
    shinyApp(ui, server)
  
  }
  </code></pre>