[Rd] ... (dotMethods) and cbind/rbind: how to give the signature?
Claudia Beleites
cbeleites at units.it
Mon Dec 22 15:26:50 CET 2008
Dear List,
I'm struggling with the signature writing cbind/rbind functions for a S4
class.
First of all, I'm very happy that it is now possible to dispatch on ...
I follow the example for "paste" in ?dotMethods, which works as far as this:
### start example
setClass ("cbtest",
representation = representation (data = "data.frame"),
prototype = prototype (data = data.frame (spc = I (matrix (rnorm
(15) , 3, 5)))
)
)
a <- new ("cbtest")
a
setMethod("cbind2", signature (x = "cbtest", y = "cbtest"),
function (x, y){
x at data$spc <- cbind (x at data$spc, y at data$spc)
x
}
)
setMethod("cbind2", signature (x = "cbtest", y = "missing"), function (x, y)
x)
cb.cbind <- function (..., deparse.level){
dots <- list (...)
for (i in seq_along (dots)[-1])
dots[[1]] <- cbind2 (dots[[1]], dots[[i]])
dots[[1]]
}
cbind2 (a, a)
cb.cbind (a, a, a)
cbind (a, a, a)
setGeneric ("cbind", signature = signature("..."))
setMethod ("cbind", "cbtest",
function (..., deparse.level) cb.cbind (...))
cbind (a, a, a)
cbind (a, a, a, deparse.level = 1)
### end example
However, I get the following message:
with setGeneric
Creating a generic for "cbind" in package ".GlobalEnv"
(the supplied definition differs from and overrides the implicit generic in
package "base": Signatures differ: (...), (deparse.level))
How do I specify the correct signature?
Furthermore: as I do not want to do anything with "deparse.level", I'd rather
specify it as "missing" in setMethod. But again, I don't get the signature
correct.
I tried
setGeneric ("cbind", signature = signature (...="...", deparse.level =
"integer"))
and
setGeneric ("cbind", signature = signature ("...", deparse.level = "integer"))
both give:
Fehler in makeGeneric(name, fdef, fdeflt, group = group, valueClass =
valueClass, :
Nicht-Argumente in der Signatur: integer
What is my mistake?
Thanks a lot for your help!
Claudia
> version
_
platform i486-pc-linux-gnu
arch i486
os linux-gnu
system i486, linux-gnu
status
major 2
minor 8.0
year 2008
month 10
day 20
svn rev 46754
language R
version.string R version 2.8.0 (2008-10-20)
--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste
phone: +39 (0 40) 5 58-34 47
email: cbeleites at units.it
More information about the R-devel
mailing list