[R] How to understand whether a class is a S3 class?

David Winsemius dwinsemius at comcast.net
Mon Aug 2 16:56:42 CEST 2010


On Aug 1, 2010, at 2:08 PM, Megh Dal wrote:

> Hi, is there any way to say: "this class 'x' is a S3 class?" For  
> example what is the type of class "data.frame"? Is it a S3 class or  
> S4?

S3 and S4 refer to methods, i.e. functions;  "class" is an attribute  
of objects. And I am not sure that the phrase "type of class" has any  
meaning. A data.frame is a list with the class attribute of  
"data.frame".  There are a variety of functions that will return the  
class, type, and mode of an object, and the function call  
methods("fn") will return the registered S3 methods for a generic  
function with name == "fn". The showMethods() function will do the  
same for S4 methods but needs somewwhat different arguments.

?methods
?class
?showMethods

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list