Rya*_*son 6 methods r introspection s4
在R中是否有一种方法可以获得在S4类上定义的所有方法的列表,给定该类的名称?
编辑:我知道showMethods可以向我展示所有方法,但我想以编程方式操作列表,所以这没有用.
也许这会很有用:
mtext <- showMethods(class="SpatialPolygons", printTo =FALSE )
fvec <- gsub( "Function(\\:\\s|\\s\\\")(.+)(\\s\\(|\\\")(.+$)",
"\\2", mtext[grep("^Function", mtext)] )
fvec
[1] ".quad" "[" "addAttrToGeom"
[4] "area" "as.data.frame" "click"
[7] "coerce" "coordinates" "coordnames"
[10] "coordnames<-" "coords" "disaggregate"
[13] "extract" "fromJSON" "isDiagonal"
[16] "isTriangular" "isValidJSON" "jsType"
[19] "over" "overlay" "plot"
[22] "polygons" "polygons<-" "rasterize"
[25] "recenter" "spChFIDs" "spsample"
[28] "spTransform" "text" "toJSON"
Run Code Online (Sandbox Code Playgroud)
原始版本没有在mtext中正确提取引用的非S4泛型,例如:
[60] "Function \"jsType\":"
[61] " <not an S4 generic function>"
Run Code Online (Sandbox Code Playgroud)