gl() in S -- puzzle

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
30 Jun 1998 12:28:09 +0200


Martin Maechler <maechler@stat.math.ethz.ch> writes:

> gl <- function (n, k, length = n * k, labels = 1:n, ordered = FALSE) 
>   (if(ordered) get("ordered",mode="function") else factor)(
>                                rep(rep(1:n, rep(k, n)), length = length),
>                                labels = labels)

Tried following my own advice and it didn't work... However, after a
bit of fiddling, I realised that this boils down a bug that I've
stumbled across before:

> test<-function(sin)get("sin",mode="function") 
> test()
.Argument(, sin = )
> test(2)
[1] 2

I.e. get() is ignoring its mode= argument when used inside a function!

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._