[R] setMethod

Hadley Wickham h.wickham at auckland.ac.nz
Wed Feb 18 01:04:29 CET 2004


I'm having problems understanding how setMethod works.  I'm trying to 
create a class specfic method for xyplot, so I thought I should do 
something like this:

setMethod("xyplot",
	signature(data = "marrayRaw"),
	function(formula, data, ...) {
		xyplot.ma(formula, do.something.with.data(data), ...)
	}
)

but I get the following error:

In method for function "xyplot": Expanding the signature to include omitted
arguments in definition: allow.multiple = "missing", outer = "missing",
auto.key = "missing", aspect = "missing", layout = "missing", panel =
"missing", prepanel = "missing", scales = "missing", strip = "missing",
groups = "missing", xlab = "missing", xlim = "missing", ylab = "missing",
ylim = "missing", subscripts = "missing", subset = "missing"
Error in .MakeSignature(new("signature"), def, signature) :
         The names in signature for method (formula, data, , , , , , , , 
, , , , , , , , , ) don't match function's arguments
(formula, data, allow.multiple, outer, auto.key, aspect, layout, panel, 
prepanel, scales, strip, groups, xlab, xlim, ylab, ylim, subscripts, subset)

What I am doing wrong?  I have tried using the full argument list for 
xyplot (where I have function(formula, data, ...) above) but then I run 
into problems passing on the arguments that have no defaults (eg. xlab, 
ylab).

Thanks for you help,

Hadley




More information about the R-help mailing list