Re: [R] inheritence in S4

2008-03-27 Thread Martin Morgan
[EMAIL PROTECTED] wrote: > Sorry to come back on callNextMethod, I am still not very confident > about it. > > Consideres the following (there is a lot of code, but very simple with > almost only some cat) : > > -- > setClass("A",representation(a="numeric")) > setValidity("A",fu

Re: [R] inheritence in S4

2008-03-27 Thread cgenolin
Sorry to come back on callNextMethod, I am still not very confident about it. Consideres the following (there is a lot of code, but very simple with almost only some cat) : -- setClass("A",representation(a="numeric")) setValidity("A",function(object){cat(" * Valid A *\n")

Re: [R] inheritence in S4

2008-03-24 Thread Martin Morgan
[EMAIL PROTECTED] wrote: >> The code example is incomplete, so I don't really know why one version >> assigned y=3 for you and the other did not; for me, neither version >> did the assignment. > > I probably add the return in the mail without imagining il will change > things. > > My question

Re: [R] inheritence in S4

2008-03-24 Thread cgenolin
> The code example is incomplete, so I don't really know why one > version assigned y=3 for you and the other did not; for me, neither > version did the assignment. I probably add the return in the mail without imagining il will change things. My question was more on the use of ... versus the a

Re: [R] inheritence in S4

2008-03-24 Thread Martin Morgan
[EMAIL PROTECTED] wrote: >> callGeneric is an advanced topic. > > Ok, when I will be older :-) > >>> * >>> This works : >>> >>> setMethod("initialize","B", >>> function(.Object,..., yValue){ >>> callNextMethod(.Object, ..., y=yValue) >>>

Re: [R] inheritence in S4

2008-03-24 Thread cgenolin
> callGeneric is an advanced topic. Ok, when I will be older :-) >> * >> This works : >> >> setMethod("initialize","B", >> function(.Object,..., yValue){ >> callNextMethod(.Object, ..., y=yValue) >> return(.Object) >> }) >> new("

Re: [R] inheritence in S4

2008-03-24 Thread Martin Morgan
[EMAIL PROTECTED] wrote: > Hi Martin > > I am re reading all the mail we exchange with new eyes because of all > the thing I learn in the past few weeks. That very interesting and some > new question occurs... > > *** > Once, you speak about callGeneric : > > se

Re: [R] inheritence in S4

2008-03-24 Thread cgenolin
Hi Martin I am re reading all the mail we exchange with new eyes because of all the thing I learn in the past few weeks. That very interesting and some new question occurs... *** Once, you speak about callGeneric : setClass("A", representation(x="numeric")) setC

Re: [R] inheritence in S4

2008-03-05 Thread Christophe Genolini
Hi Martin I was not that much speaking about what we can do, but more about what we can't. We can't decide that object will be 'never empty', we have to allow empty oject, otherwise new("A") will not work and that will be problematic. So, at this point, I see : - it is necessary to allow the

Re: [R] inheritence in S4

2008-03-05 Thread Martin Morgan
[EMAIL PROTECTED] writes: > Well well well... You're partly misunderstanding... > To summarize : let assume that A is a class (slot x) and C is a class > containing A (A and slot y) - as(c,"A") calls new("A"). So new("A") > HAS TO works, you can not decide to forbid empty object (unless you > de

Re: [R] inheritence in S4

2008-03-05 Thread cgenolin
Well well well... To summarize : let assume that A is a class (slot x) and C is a class containing A (A and slot y) - as(c,"A") calls new("A"). So new("A") HAS TO works, you can not decide to forbid empty object (unless you define setAs("C","A") ?) - In addition, any test that you would like to

Re: [R] inheritence in S4

2008-03-04 Thread Martin Morgan
[EMAIL PROTECTED] writes: > Hi Martin, thanks for your answer > >> But a couple >> of other quick points. I would have written >> >> setMethod("initialize", "A", >> function(.Object, ..., xValue=numeric(0)){ >> callNextMethod(.Object, ..., x=xValue) >> }) >> > > I am

Re: [R] inheritence in S4

2008-03-04 Thread cgenolin
Hi Martin, thanks for your answer > But a couple > of other quick points. I would have written > > setMethod("initialize", "A", > function(.Object, ..., xValue=numeric(0)){ > callNextMethod(.Object, ..., x=xValue) > }) > I am not that much familiar with S3... In our

Re: [R] inheritence in S4

2008-03-03 Thread Martin Morgan
Hi Christophe -- This is a variant of the problem that Jim Regetz is having in a thread in R-devel. Here's where the trouble is > as(c, "A") Error in .local(.Object, ...) : argument "value" is missing, with no default By default, 'as(c, "A")' will create a new instance of it's second argument

Re: [R] inheritence in S4

2008-03-03 Thread Christophe Genolini
Thanks Martin Well it works except that "as" seems to not like the "initialize" method : the following code (that is the same than yours with some initialize for A B and C) does not compile. It seems that as(c,"A") does not work if we definie a initialize for A... --- 8< -- setClas

Re: [R] inheritence in S4

2008-03-01 Thread Martin Morgan
Hi Christophe -- I don't know whether there's a particularly elegant way. This works setClass("A", representation(x="numeric")) setClass("B", representation(y="numeric")) setClass("C", contains=c("A", "B")) setMethod("show", "A", function(object) cat("A\n")) setMethod("show", "B", function(obje

[R] inheritence in S4

2008-02-29 Thread cgenolin
Hi the list I define a class A (slot a and b), a class C (slot c and d) and a class E that inherit from A and B. I define print(A) and print(B). For print(C), I would like to use both of them, but I do not see how... Thanks for your help... Christophe -