From p.dalgaard@biostat.ku.dk  Tue Jun 30 10:13:13 1998
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 30 Jun 1998 11:13:13 +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: <x2u3536ymu.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)
...
> 	S> gl(3,4,24, ordered=T)
> 
> 	Error in gl: object of mode ( and length 2 used as string value: (if(ordered) get("ordered", mode = "function") else factor)
> 		. . .
...
> ---
> what's the problem in S ?

A bug, probably. It might help to eval() the if(ordered)... bit
explicitly or split the expression i two steps {FUN<-if(ordered); FUN(...)}

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