gl() in S -- puzzle

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
30 Jun 1998 11:13:13 +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)
...
> 	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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._