R-alpha: Re: select.frame

Peter Dalgaard BSA p.dalgaard@kubism.ku.dk
16 Apr 1997 01:51:18 +0200


Ross Ihaka <ihaka@stat.auckland.ac.nz> writes:

> 2. As written, the function uses R scoping rules to pass the value of
>    the variable "nm" into the body of "subst.exp", and so the function
>    will not work in S.  It might be better to pass "nm" as an argument
>    so that the function is portable.

..and same thing applies to subst.exp itself, isn't that so? As
written, subst.exp would not be able to find subst.exp. Let's see:

[Splus]
> g<-function(n){f<-function(n)ifelse(n,1,n*f(n));f(n)}
> g(3)
Error in f(n): couldn't find function "f"
Dumped

Right. One of the major annoyances in S, actually. This has bugged be
always. You need to put the function in the "evaluation frame" or
define it globally. Maybe one should just leave it and let S solve the
porting problems? ;^)

> 3. It might be good to check that only ":" expressions allowed.

Hum. I was beginning to like the idea that you could put complicated
expressions in there, as in

select.frame(dfr, seq(visit1.1st, length=10, by=3))

when you have visit1.1st, visit1.2nd, visit1.3rd, .... visit10.3rd and
you want to look at the *.1st measurements. The semantics are that
variable names get replaced by their column numbers, if they exist in
the frame, and all that is required is that the resulting integer
expression makes sense. 

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