From p.dalgaard@biostat.ku.dk  Tue Jun 30 11:28:09 1998
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 30 Jun 1998 12:28:09 +0200
Subject: gl() in S -- puzzle
In-Reply-To: Martin Maechler's message of Tue, 30 Jun 1998 10:45:38 +0200
References: <199806300845.KAA04635@sophie.ethz.ch>
Message-ID: <x27m1zyyiu.fsf@blueberry.kubism.ku.dk>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


gl() in S -- puzzle
Peter Dalgaard BSA