[R] Find the package of a class given classname

Hadley Wickham h.wickham at gmail.com
Mon Jan 13 15:42:09 CET 2014


>> How to find the package of a class given classname?
>> For example, there is a class called GAlignments, I want to do something
>> like
>> attr("GAlignments", "package") that gives you the package where the class
>> is defined? But of course, attr("GAlignments", "package") won't work...
>
> You didn't say whether you wanted to be able to do this
> programmatically.
>
> If that's the case maybe you're lucky and the package where the class
> is defined is already attached to your session. In that case:
>
>   > attr(class(new("GAlignments")), "package")
>   [1] "GenomicRanges"

Or maybe findClass?

>
> Otherwise, if the package in question is installed but not attached
> you can still do:
>
>   ??`GAlignments-class`

Or class?GAlignments

Hadley

-- 
http://had.co.nz/




More information about the R-help mailing list