为了回答这个问题,我尝试extract
从 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.
由于它是 S4 功能,因此我遵循了此答案的指南:
> 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"
但后来陷入了这个错误:
> getMethod(extract,signature="SpatialPolygons")
Error in as.vector(x, "character") :
cannot coerce type 'closure' to vector of type 'character'
我目前在 R 2.14.2 上,在 Mac 上,包的版本raster
是 1.9-92。虽然,我在更改日志中没有看到任何表明这是版本问题的内容。
我也尝试了以下但没有成功:
> getMethod("extract",signature="SpatialPolygons")
Error in getMethod("extract", signature = "SpatialPolygons") :
No method found for function "extract" and signature SpatialPolygons