Re: [R] Object equality for S4 objects

2009-07-30 Thread Stavros Macrakis
On Thu, Jul 30, 2009 at 4:03 PM, Martin Morgan wrote: > S4 objects are mutable in the sense that one can write replacement methods > for them Understood, but I don't think that's the usual meaning of 'mutable'. -s __ R-help@r-project.org m

Re: [R] Object equality for S4 objects

2009-07-30 Thread Martin Morgan
Stavros Macrakis wrote: On Thu, Jul 30, 2009 at 12:01 PM, Martin Morgan wrote: S4 objects do not have the semantics of environments, but of lists (or of most other R objects), so it is as meaningful to ask why identical(s1, s2) returns TRUE as it is to ask why identical(list(x=1), list(x=1)) r

Re: [R] Object equality for S4 objects

2009-07-30 Thread Stavros Macrakis
On Thu, Jul 30, 2009 at 12:01 PM, Martin Morgan wrote: > S4 objects do not have the semantics of environments, but of lists (or of > most other R objects), so it is as meaningful to ask why identical(s1, s2) > returns TRUE as it is to ask why identical(list(x=1), list(x=1)) returns TRUE. Thanks

Re: [R] Object equality for S4 objects

2009-07-30 Thread Martin Morgan
Hi Stavros -- Stavros Macrakis writes: > To test two environments for object equality (Lisp EQ), I can use 'identity': > >> e1 <- environment(local(function()x)) >> e2 <- environment(local(function()x)) >> identical(e1,e2) # compares object identity > [1] FALSE >> identical(

[R] Object equality for S4 objects

2009-07-29 Thread Stavros Macrakis
To test two environments for object equality (Lisp EQ), I can use 'identity': > e1 <- environment(local(function()x)) > e2 <- environment(local(function()x)) > identical(e1,e2) # compares object identity [1] FALSE > identical(as.list(e1),as.list(e2))# compares values as na