[R] Bug or failing understanding?

Don MacQueen macq at llnl.gov
Wed Jun 26 19:47:19 CEST 2002


The way I look at this, perhaps naively, is this:
   > test <- function(x=x) x*x
is defining a function, whereas
   lm.fit(x, y, offset = offset, ...)
is calling a function.

The syntax may look the same, but the operation is different.

lm.fit is defined
   > args(lm.fit)
   function (x, y, offset = NULL, method = "qr", tol = 1e-07, ...)
so it is not applicable as a counter-example.

-Don

At 11:46 AM -0400 6/26/02, 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?
>
>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
>_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
--------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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