Is there a way in R to get a list of all methods defined on an S4 class, given the name of that class?
Edit: I know that showMethods
can show me all the methods, but I want to manipulate the list programmatically, so that's no good.
Maybe this would be useful:
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"
The original version did not properly extract the quoted non S4 generics in mtext such as:
[60] "Function \"jsType\":"
[61] " <not an S4 generic function>"
Are you looking for showMethods()
?
library(sp)
showMethods(class="SpatialPolygons")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With