Re: [R] setAs vs setIs

From: Christophe Genolini <>
Date: Mon, 17 Mar 2008 09:42:09 +0100

I works, great !
So using your code, we can define 'as','as<-' and 'is' with setIt. Is there still any interest using setAs ?

> It seems to me your problem here is simply that you did not define a
> coerce cal in setIs, so it does not know how to turn a C object into a
> B object, which is what you ask it to do here. It knows how to test if
> C object is also a B object, because of the test function you
> provided, and it can do the replacement you ask it in as(c,"B") <-b
> because of the replace command you provided, but the third part is
> missing. Perhaps something like this:
> setIs("C","B",
> test=function(object){return(object_at_c>0)},
> replace=function(from,values){
> from_at_c <- values_at_b^3
> return(from)
> },
> coerce=function(from) {
> new("B",b=from_at_c^(1/3))
> }
> ) mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 17 Mar 2008 - 08:46:20 GMT

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 Mon 17 Mar 2008 - 10:30:22 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive