[Rd] signature() and setMethod() problems
Robin Hankin
r.hankin at noc.soton.ac.uk
Thu Jun 28 14:38:32 CEST 2007
I am having difficulty using signature().
I have one virtual class (onion) and
two nonvirtual classes (quaternion and octonion).
containing onion.
I want to define three distinct sets of
arithmetic operations: one for onion-onion,
one for onion-real, and one for real-onion [this
is more computationally efficient than
coercing reals to onions and then using onion-onion
operations].
Executing the following code gives an error [R-2.5.0]
at the first call to setMethod():
Error in match.call(fun, fcall) : unused argument(s) (o1 = "onion",
o2 = "onion")
Why is this, and what would the List suggest
is Best Practice here?
setClass("onion",
representation = "VIRTUAL"
)
setClass("quaternion",
representation = representation(x="matrix"),
prototype = list(x=matrix(numeric(),0,4)),
contains = "onion"
)
setClass("octonion",
representation = representation(x="matrix"),
prototype = list(x=matrix(numeric(),0,8)),
contains = "onion"
)
".onion.onion.arith" <- function(o1,o2){stop("OO not implemented")}
".onion.real.arith" <- function(o,r){stop("OR not implemented")}
".real.onion.arith" <- function(r,o){stop("RO not implemented")}
setMethod("Arith", signature
(o1="onion",o2="onion" ), .onion.onion.arith)
setMethod("Arith", signature(o="onion",r="ANY" ), .onion.real.arith)
setMethod("Arith", signature(r="ANY",o="onion" ), .real.onion.arith)
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
More information about the R-devel
mailing list