Re: [Rd] Testing for a reference class object

2011-03-10 Thread John Chambers
There is a virtual class "refClass" that all reference classes subclass, so is(x, "refClass") is the natural test, as in: > foo <- setRefClass("foo", fields = "bar") > x <- foo$new() > is(x, "refClass") [1] TRUE On 3/10/11 7:40 AM, Jeffrey Horner wrote: Hi all, I've constructed the following

[Rd] Testing for a reference class object

2011-03-10 Thread Jeffrey Horner
Hi all, I've constructed the following function to test whether or not an object was created from a reference class: isRefClassObject <- function(x) isS4(x) && is.environment(attr(x,'.xData')) && exists('.refClassDef',attr(x,'.xData')) but I'm unsure if it's a complete test or if there's a bette