extra arguments to generic functions & bug in model.frame
Jim Robison-Cox
jimrc@mathfs.math.montana.edu
Wed, 17 Jun 1998 12:22:04 -0600 (MDT)
R developers,
2 things: a bug in model.frame and a question about setup of generic
functions.
I don't understand the following behavior for generic functions:
Suppose I'm working with the cats data in the MASS library and I want to
create a formula object to model Hwt on Sex:
# This works:
> formula(Hwt ~ Sex)
Hwt ~ Sex
# But the following does not:
> formula(Hwt ~ Sex, data = cats)
Error in formula.formula(Hwt ~ Sex, cats) : unused argument to function
# because I used an extra argument.
The odd thing to me, is that formula() itself allows the argument:
> formula
function (x, ...)
UseMethod("formula")
But formula.default does not:
> args(formula.default)
function (x)
The same thing happens with terms:
> args(terms)
function (x, ...)
> args(terms.default)
function (x)
And this caused me a problem when using model.frame() since
model.frame.default includes the lines:
if (!inherits(formula, "terms"))
formula <- terms(formula, data = data)
Using 2 arguments in term() is a bug since hitting the line
will cause an error:
Error in terms.default(formula, data = data) : unused argument to function
Summary:
1. There seems to be a bug in model.frame() using terms() with 2 arguments.
2. What is standard practice for setting up instances of a generic function?
It seems sensible to me that argument lists should not shrink when
going from the generic function to an instance of that function.
Cheers,
Jim
Jim Robison-Cox ____________
Department of Math Sciences | | phone: (406)994-5340
2-214 Wilson Hall \ BZN, MT | FAX: (406)994-1789
Montana State University | *_______|
Bozeman, MT 59717 \_| e-mail: jimrc@math.montana.edu
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._