Reputation: 18749
To answer this question, i tried to look at the source code of function extract
from package raster
.
> library(raster)
> extract
standardGeneric for "extract" defined from package "raster"
function (x, y, ...)
standardGeneric("extract")
<environment: 0x859c3e4>
Methods may be defined for arguments: x, y
Use showMethods("extract") for currently available ones.
Since it is a S4 function, i followed the guideline from this answer:
> showMethods(extract)
Function: extract (package raster)
x="Raster", y="data.frame"
x="Raster", y="Extent"
x="Raster", y="matrix"
x="Raster", y="SpatialLines"
x="Raster", y="SpatialPoints"
x="Raster", y="SpatialPolygons"
x="Raster", y="vector"
But then fell on this error:
> getMethod(extract,signature="SpatialPolygons")
Error in as.vector(x, "character") :
cannot coerce type 'closure' to vector of type 'character'
I'm currently on R 2.14.2, on a Mac and the version of package raster
is 1.9-92. Although, i didn't see anything in the changelogs suggesting it's a version issue.
I also tried the following without success:
> getMethod("extract",signature="SpatialPolygons")
Error in getMethod("extract", signature = "SpatialPolygons") :
No method found for function "extract" and signature SpatialPolygons
Upvotes: 2
Views: 1056
Reputation: 59970
You haven't supplied the whole signature....
A signature is a named or unnamed vector of character strings. If named, the names must be formal argument names for the generic function. Signatures are matched to the arguments specified in the signature slot of the generic function
getMethod("extract" , signature = c( x = "Raster" , y = "SpatialPolygons") )
Upvotes: 4