title: R Shiny Error in unclass(x) : cannot unclass an environment using dplyr filter function
body: <p>I am attempting to filter a data set in a reactive function so that I can move a slider up and down and change the size of the data set.</p>
  
  <p>I use the slider called "sliderfordata" as input to the reactive function called "yeardata"so that I use that reactive function as data input for output$chart. 
  <strong>The data set I am working with is mtcars</strong> aswell. </p>
  
  <p><strong>Error message:</strong>: 
  Error in unclass(x) : cannot unclass an environment</p>
  
  <p>This occours when I choose a file to upload as data, which maps to reactivefunc that reads the data file from the file path.</p>
  
  <p><strong>Any help is appreciated</strong>!</p>
  
  <p><strong>Server Code</strong></p>
  
  <pre><code>library("dplyr")
  server &lt;- function(input, output, session) {
  
  
    yeardata &lt;- reactive({
      mtcarslist &lt;- reactivefunc()
      df &lt;- mtcarslist %&gt;%
        filter(mpg &gt;= input$sliderfordata)
  
  
    })
    output$chart &lt;- reactive({
  
      dataframe &lt;- yeardata()
      gggraph &lt;-
        ggplot(dataframe, aes(x = mpg , y = hp))
      gggraph &lt;- gggraph + geom_point()
      gggraph
    })
  
  
  
    reactivefunc &lt;- reactive(
      csv &lt;- read.csv(input$file$datapath)
    )
  
  
    # scatter plot the mtcars dataset - mpg vs hp
    output$graph &lt;- renderPlot({
      # filename = input$file$datapath
      # csv &lt;- read.csv(filename)
  
      # If more than 1 category, you can do this (put in a if state)
      # If filepath is put in
      csvread &lt;- reactivefunc()
      x_axis &lt;- input$xaxis
      y_axis &lt;- input$yaxis
      rangemin &lt;- as.numeric(input$val1)
      rangemax &lt;- as.numeric(input$val2)
  
      # csv &lt;-
      #   csvread %&gt;%
      #   filter(
      #     x_axis &lt;- csvread$x_axis &lt; as.numeric(input$val2)
      #     # y_axis &lt;- csvread$y_axis &lt; as.numeric(input$val2)
      #   )
  
      size &lt;- input$size
      color &lt;- input$color
      gg &lt;-
        ggplot(reactivefunc(), aes_string(x = x_axis, y = y_axis, size = size, colour = color))
      gg &lt;- gg + geom_point()
      gg
    })
  
    output$hist &lt;- renderPlot({
        x_axis &lt;- input$xaxis
        csvread &lt;- reactivefunc()
  
  
        ggplot(reactivefunc(), aes_string(x= x_axis)) + geom_histogram(bins = input$bins)
  
    })
  
    # To display the mtcars dataset on the left side in the app
    output$data &lt;- renderTable({
      reactivefunc()
    })
  
  
    output$mytable = DT::renderDataTable(reactivefunc(), selection = list(target = 'row+column'))
  
  
    # brushedPoints returns the row of data under the brush
    # brush information comes from ui to server using brushId and can be accessed using input$brushId
  
    output$data_brush &lt;-  renderTable({
      n = nrow(brushedPoints(reactivefunc(), brush = input$plot_brush)) # row count will be 0 when no selection made by the brush
      if(n==0)  
        return()
      else
        brushedPoints(reactivefunc(), brush = input$plot_brush) # return rows
      # argument allRows = TRUE can also be used
      ## It will add another column (selected_) to the actual dataset. True indicates that data point 
      # corresponding to that row was under the brush. False means data corresponding to that row wasn't selected by brush
  
  
  
    })
  }
  </code></pre>
  
  <p><strong>UI Code:</strong></p>
  
  <pre><code>library(shiny)
  library(ggplot2)
  library(shinydashboard)
  
  ## ui code starts here ## 
  data &lt;- read.csv(file.choose())
  datacolnames &lt;- colnames(data)
  datarownames&lt;- data[,1]
  
  
  datacolnames &lt;- datacolnames[-1]
  length &lt;- length(datacolnames)
  length
  data
  # Works!@
  
    maxvector &lt;- c()
    for (i in 2:length) {
      maxvector &lt;- append(maxvector, max(data[,i]))
      i &lt;- i + 1
    }
  maxvector &lt;- max(maxvector)
  maxvector
  
  minvector &lt;- c()
  for (i in 2:length) {
    minvector &lt;- append(minvector, min(data[,i]))
    i &lt;- i + 1
  }
  minvector &lt;- min(minvector)
  minvector
  
  
  
  
  
  
  
  
  
  
  
  
  
  # max &lt;- max(data[,c(:11]))
  # min &lt;- min(data[,2])
  # max
  
  ui &lt;- 
    dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody(
        h4("Interactive plots - select data points in plot - return the rows of data that are selected by brush"),
  
        # brush argument will enable the brush, sends the data point information to the server side
        # at the server side the data points under the brush related information can be read through input$BRUSHID
        plotOutput(outputId = "graph", brush = "plot_brush"), # brush ID is plot_brush
        plotOutput("chart"),
  
        fluidRow(
          box(width = 5,title = "Charting", status = "warning", solidHeader = T,
              fileInput("file", "Upload the File"),
              h5("Max file size to upload is 5 MB"),
              radioButtons("sep", "Seperator", choices = c(Comma = ",", Period = ".")),
              selectInput("xaxis","Select the Model number", datacolnames),
              selectInput("yaxis", "Select the Type number", datacolnames),
              selectInput("size", "Select the Size", datacolnames),
              selectInput("color", "Select the Color", datacolnames),
              textInput("val1", "Type in the Beginning Value you Want to see", minvector),
              textInput("val2", "Type in the End Value you want to see", maxvector),
              sliderInput("bins", "Data Range", min = minvector, max = maxvector, 10),
  
              sliderInput("sliderfordata", "Range of X Data Values", min = 10, max = 100, value = 10)
              # sliderInput("y", "Range of Y Data Values", min = 10, max = 100, value = c(10,100))
  
  
  
  
  
  
  
              # Instead of sliders, we could have text inputs that map to the indexing
              # sliderInput("obs", "Data Range:",  
              #             min = minvector, max = maxvector, value = c(0,472))
          ),
          column(width=5, tags$b(tags$i("Rows corresponding to datapoints under brush")),  tableOutput("data_brush"), offset = 2)
  
        ),
        fluidPage(
          plotOutput("hist")
        ),
  
  
        # left side actual dataset and right side the rows for datapoints selected by brush
        # defined the width of each column and also some styling (bold &amp; italics) using tags
        fluidPage(
          box(width = 12, tags$b(tags$i("Actual Dataset")), DT::dataTableOutput("mytable"))
        )
  
  
      )
    )
  
  # download the data button
  </code></pre>