[S] "..." in group methods

joyet pierre (pierre.joyet@basler.ch)
Fri, 18 Sep 1998 10:59:03 +0200


I have a class "dreieck" which inherits from class "data.frame". An
element of this class is simply a data frame with 3 columns which
represent a ragged array; the two first columns are the indices, the
third one is the value of the cell. Functions print and as.matrix have
methods for this class. Now I would like functions of the Math group to
act only on the third column; I have tried the following function:

Math.dreieck <- function(x, ...)
{
x[, 3] <- do.call(.Generic, list(x[, 3], ...))
x
}

It works well for example when I call log(object):

> object
UJ AJ Z
1 1 1 2.000000
2 1 2 2.718282
3 2 1 3.000000
> log(object)
UJ AJ Z
1 1 1 0.6931472
2 1 2 1.0000000
3 2 1 1.0986123

but the problem arises when I have additional arguments:
> trace(c("log", "Math.dreieck"))
> log(object, base = 2)
On entry: log(object, base = 2)
On entry: Math.dreieck(x)
On entry: log(c(2, 2.71828182845904,
3))
UJ AJ Z
1 1.442695 1.442695 1.000000
2 1.442695 2.885390 1.442695
3 2.885390 1.442695 1.584963

Moreover, the result's class is NULL (it was c("dreieck", "data.frame")
in log(object))

Can anybody tell me firstly why this happens, and secondly what would be
the right way of doing what I want? (I have also tried using NextMethod,
without much success.)

Many thanks in advance

Pierre Joyet
Baloise Insurance Company
Basle, Switzerland
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news