Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out all the methods defined for a class in R?

Tags:

methods

oop

class

r

In R, I want to get an idea of what I can do with a particular class (specifically, the "Mart" class from the "biomaRt" package in BioConductor). I would like to see all the methods that are defined for this class. Is there a way to do this?

Note: The methods function does not do what I want. That function lists all the classes for which a specific method is defined, not all the methods defined for a class.

like image 573
Ryan C. Thompson Avatar asked Mar 27 '11 03:03

Ryan C. Thompson


2 Answers

Ah, but methods does do what you want. Read ?methods carefully and you will see the class= argument is what you're looking for.

require(zoo)
methods(class="zoo")

S4 classes are similar, but you need to use showMethods instead.

require(timeSeries)
showMethods(classes="timeSeries")
like image 151
Joshua Ulrich Avatar answered Oct 30 '22 06:10

Joshua Ulrich


If your class is an S3 class then you use the methods function, but specify the class argument.

If it is an S4 class then use showMethods.

like image 24
Greg Snow Avatar answered Oct 30 '22 08:10

Greg Snow