[Rd] methods package

ml-it-r-devel at epigenomics.com ml-it-r-devel at epigenomics.com
Thu Mar 5 11:14:48 CET 2009


Terry Therneau wrote:
>   I'm working on the next version of coxme, one step of which is converting
> the bdsmatrix library from Splus to R.  Actually, it is a conversion from
> S4 methods as first described in the Green book to S4 methods as they 
> currently exist.  Mostly it's going ok, but not entirely.
> 
>   1. The biggest issue is lack of documentation.  The online help pages have
> not been a help; they keep saying it's "as found in the green book - almost".
> I've looked for the package on CRAN in the hopes for more there, but can't
> find it.  Perchance there is something obvious that I am missing?
> 
>   2. The changes are small but numerous.  The current one that has me puzzled
> is a method for addition:
>    setMethod(Ops, signature=c('numeric', 'bdsmatrix'), ....
> 
> Let xmat be ordinary and bmat be a bdsmatrix.  In the old code "xmat + bmat"
> fell to this method (which knows what to do), in the current R I get
> failure due to no method found.  is.numeric(xmat) is TRUE.
>    What is the fix?

Assuming xmat to be a numeric matrix e.g. diag(n).
S4 inheritance will be determined by is() and
is(xmat, "numeric") will be FALSE

So one solution is to provide explicit methods for signature 'matrix' i.e.
 setMethod(Ops, signature=c('matrix', 'bdsmatrix'), ....
 setMethod(Ops, signature=c('bdsmatrix', 'matrix'), ....

  Matthias

>  3. In the green book the examples used .Dim and .Dimnames slots, the Matrix
> library uses Dim and Dimnames.  Is there a good reason to choose one or the
> other?
> 
>   I'll be out of town for the next few days (son's wedding) so instant response
> is not necessary.
> 
> 	Terry Therneau
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 


-- 
Matthias Burger                     Project Manager/ Biostatistician
Epigenomics AG    Kleine Praesidentenstr. 1    10178 Berlin, Germany
phone:+49-30-24345-0                            fax:+49-30-24345-555
http://www.epigenomics.com           matthias.burger at epigenomics.com
--
Epigenomics AG Berlin           Amtsgericht Charlottenburg HRB 75861
Vorstand:                           Geert Nygaard (CEO/Vorsitzender)
                                            Oliver Schacht PhD (CFO)
Aufsichtsrat:   Prof. Dr. Dr. hc. Rolf Krebs (Chairman/Vorsitzender)



More information about the R-devel mailing list