title: R: error when trying a loop with dplyr filter function
body: <p>Trying to simplify and make my code reproducible, I have the following loop code which aims to subset a data frame and store every subsetting in a new variable:</p>
  
  <pre><code>types &lt;- c("POINT", "NONPOINT", "ON-ROAD", "NON-ROAD")
  
  for (i in seq_along(types)) {
     paste("type", types[i], sep = "") &lt;- filter(NEI$Emissions, NEI$type == types[i])
  }
  </code></pre>
  
  <p>I expected my loop to store every subsetting (4 subsettings) in a new variable called "type" and the corresponding string. Instead of it, I get the following error: </p>
  
  <blockquote>
    <p>"Error in UseMethod("filter_") : 
      no applicable method for 'filter_' applied to an object of class "c('double', 'numeric')"</p>
  </blockquote>
  
  <p>I've already tried to modify the class of type coercing it to be a string through <code>as.character(types)</code> but got no success.</p>
  
  <p>Edit: the output of <code>head(NEI)</code> is the following:</p>
  
  <pre><code>   fips      SCC  Pollutant Emissions  type year
  4  09001 10100401  PM25-PRI    15.714 POINT 1999
  8  09001 10100404  PM25-PRI   234.178 POINT 1999
  12 09001 10100501  PM25-PRI     0.128 POINT 1999
  16 09001 10200401  PM25-PRI     2.036 POINT 1999
  20 09001 10200504  PM25-PRI     0.388 POINT 1999
  24 09001 10200602  PM25-PRI     1.490 POINT 1999
  </code></pre>