[R] Bug or failing understanding?
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Wed Jun 26 18:02:00 CEST 2002
On Wed, 26 Jun 2002, kjetil halvorsen wrote:
> Hola!
>
> I seem to remember i used to have the same name of argument and default
> value in argument list to functions, but (rw1.5.1) this seems not to
> work:
>
> > x <- 3
> > test <- function(x=x) x*x
> > test(7)
> [1] 49
> > test()
> Error in test() : recursive default argument reference
>
>
> here is a code fragment from lm() using the same syntax:
>
>
> else {
> x <- model.matrix(mt, mf, contrasts)
> z <- if (is.null(w))
> lm.fit(x, y, offset = offset, ...)
> else lm.wfit(x, y, w, offset = offset, ...)
>
> What is wrong?
You example is a call, and your usage is a formal argument. Yours sets the
default for `x' to x, which does not exist. lm's calls lm.fit with named
argument `offset'.
>
> Kjetil Halvorsen
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help 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-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list