title: Extracting points with polygon in R
body: <p>I'm trying to extract points by a polygon using the 'sp' package function 'over'</p>
  
  <pre><code>library(sp)
  library(rgeos)
  #my polygon plgn (many polygon features in one)
  plot(plgn)
  proj4string(plgn) = CRS("+proj=utm +zone=46 +datum=WGS84 +units=m +no_defs")
  #giving spatial reference to point data d
  coordinates(d) &lt;- ~X+Y
  proj4string(d) = CRS("+proj=utm +zone=46 +datum=WGS84 +units=m +no_defs")
  #USE overlay (there are many NAs)
  overlay=d[!is.na(over(d, plgn)),]
  </code></pre>
  
  <p>Unfortunately, I'm getting an ERROR</p>
  
  <pre><code>Error in d[!is.na(over(d, plgn)), ] : 
  matrix argument not supported in SpatialPointsDataFrame selection
  </code></pre>
  
  <p>Any idea?? Is it because my polygon contains 100s of features?</p>