title: Import raster stack and return new layer
body: <p>I am trying to import about 50 .tif files into a stack using the rasters package. Because of the large number of files I don't want to list them all out. I have tried a few methods but have been unsuccessful, including this code:</p>
  
  <blockquote>
    <p>test&lt;-stack(choose.files(),values=T)
    Error in .local(x, ...) : 
      Arguments should be Raster* objects or filenames</p>
  </blockquote>
  
  <p>In addition I want to classify a new raster based on the 50 I import. For example I have a group of polygons with the same extent (could convert to raster) and want to count the number of times a value "1" occurs in each polygon. I figure the "overlay" function would be best for this but am having trouble thinking of how to code the associated function. Any help would be appreciated.</p>