Re: [Rd] Reference Classes: shortcut like 'isS4' for Ref Classes?

From: John Chambers <jmc_at_r-project.org>
Date: Mon, 06 Jun 2011 14:38:02 -0700

As it says on the help page ?ReferenceClasses:

All reference classes inherit from the class "envRefClass"

So,

   is(x, "envRefClass")

And, less well documented but less typing:

   is(x, "refClass")
also works.

On 6/6/11 9:48 AM, Janko Thyson wrote:
> Dear list,
>
> is there a shortcut-function to check whether a class is a Reference
> Class or not? There's something like this for S4 classes
> ('isS4(object)'), but I couldn't find anything regarding Ref Classes.
>
> Currently, I'm doing it this way, which is a bit clumsy:
>
> A <- setRefClass("A", fields=list(X="numeric"))
> a <- A$new()
>
> isRefClass <- function(object, ...){
> return(getClass(class(object))@class == "refClassRepresentation")
> # getRefClass(class(object))@class == "refObjectGenerator"
> }
>
> isRefClass(a)
> [1] TRUE
>
> Regards,
> Janko
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 06 Jun 2011 - 21:46:32 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 07 Jun 2011 - 16:10:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive