[R] getSubClasses()?

Martin Morgan mtmorgan at fhcrc.org
Thu May 20 16:58:13 CEST 2010


On 05/20/2010 07:47 AM, Albert-Jan Roskam wrote:
> Hi,
> 
> Is there a built in function that returns a character vector of all
> subclasses of a given superclass? showClass(Class = "SomeClass")
> contains the info that I want, but I don't know how to access it. 

Hi Albert-Jan --

Maybe

> slotNames(class(getClass("vector")))
 [1] "slots"      "contains"   "virtual"    "prototype"  "validity"
 [6] "access"     "className"  "package"    "subclasses" "versionKey"
[11] "sealed"
> names(getClass("vector")@subclasses)
 [1] "logical"            "numeric"            "character"
 [4] "complex"            "integer"            "raw"
 [7] "expression"         "list"               "structure"
[10] "array"              "matrix"             "signature"
[13] "ObjectsWithPackage" "mts"                "ordered"
[16] "namedList"          "listOfMethods"

Martin

> getSubClasses <- function(superClass)
> return(setdiff(getClasses(.GlobalEnv), superClass)) wíll only work if
> the global enviroment isn;t filled with other class definitions.
> 
> I've seen functions that somewhat resemble it, but are not quite the
> same. Thanks in advance!
> 
> Cheers!! Albert-Jan
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> 
All right, but apart from the sanitation, the medicine, education, wine,
public order, irrigation, roads, a fresh water system, and public
health, what have the Romans ever done for us?
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> 
> 
> 
> [[alternative HTML version deleted]]
> 
> 
> 
> 
> ______________________________________________ R-help at r-project.org
> mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
> read the posting guide http://www.R-project.org/posting-guide.html 
> and provide commented, minimal, self-contained, reproducible code.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



More information about the R-help mailing list