Dear Prof. Ripley, Thanks for the clarification.
Prof Brian Ripley wrote: > Why does simply > > setMethod("apply", > signature(X = "myClass", > MARGIN = "numeric", > FUN = "function"), > function(X, MARGIN, FUN, ...) .apply.myClass(X, MARGIN, FUN, > ...)) > > not do what you want? It works for me in your example, e.g. > >> apply(myObj, 2, sum, [EMAIL PROTECTED]) > > > gives exactly the same answer as your complicated solution. > > I do wonder if you have misunderstood what '...' does. I hope not (entirely). I got a bizarre bug yesterday while working on that method/function issue which lead me (wrongly, because of a too quick diagnostic probably) to think there was a problem with the way the "..." was passed from one function to the next. That explains the complicated construct of my previous e-mail. Your solution works (of course) and is definitely simpler (!). > > I also wonder why you chose to overload a basic R function as an S4 > generic like this. If you think that thereby existing calls to > apply() will go via your S4 methods then I fear you have overlooked > the effects of namespaces. > No, I just want the user to be able to call "apply" with myClass objects without having to bother with the internal structure of these objects (which is slightly more complicated in my "real" case than on the example I sent). Thanks again, Christophe. -- A Master Carpenter has many tools and is expert with most of them.If you only know how to use a hammer, every problem starts to look like a nail. Stay away from that trap. Richard B Johnson. -- Christophe Pouzat Laboratoire de Physiologie Cerebrale CNRS UMR 8118 UFR biomedicale de l'Universite Paris V 45, rue des Saints Peres 75006 PARIS France tel: +33 (0)1 42 86 38 28 fax: +33 (0)1 42 86 38 30 web: www.biomedicale.univ-paris5.fr/physcerv/C_Pouzat.html ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html