From janko.thyson.rstuff at googlemail.com  Tue Jun  7 16:56:40 2011
From: janko.thyson.rstuff at googlemail.com (Janko Thyson)
Date: Tue, 07 Jun 2011 16:56:40 +0200
Subject: [Rd] Reference Classes: shortcut like 'isS4' for Ref Classes?
In-Reply-To: <4DED48BA.9050707@r-project.org>
References: <4DED04F1.9040200@googlemail.com> <4DED48BA.9050707@r-project.org>
Message-ID: <4DEE3C28.4070403@googlemail.com>

Thanks for the answer! Sorry, must have missed that part of the help 
page. Your second approach is exactly what I was looking for.

Regards,
Janko

On 06.06.2011 23:38, John Chambers wrote:
> 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
>



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