From p.dalgaard@kubism.ku.dk  Mon Apr 14 18:28:06 1997
From: p.dalgaard@kubism.ku.dk (Peter Dalgaard BSA)
Date: 14 Apr 1997 19:28:06 +0200
Subject: R-alpha: User friendly functions
In-Reply-To: Kurt Hornik's message of Mon, 14 Apr 1997 18:57:44 +0200
References: <x2k9md77cb.fsf@bush.kubism.ku.dk>
 <199704141657.SAA04410@aragorn.ci.tuwien.ac.at>
Message-ID: <x2208dfra1.fsf@bush.kubism.ku.dk>

Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes:

> > dfr.sel<-select.frame(dfr,age,sex,pain1:pain5)
> 
> > dfr.sub<-subset.frame(dfr,sex==1 && age > 30)
> 
> Something like that would be very nice to have.

I got a working select.frame() during the weekend. Really easy, once you
get the hang of constructions of the type

eval(as.call(subst.expr(c(as.name("c"),expression(...)))))

- with subst.expr() recursively replacing call arguments with
corresponding numbers using match(). As a bonus, it is actually
possible to do stuff like

select.frame(psychometry,seq(scale1.before,scale15.before,2))

and get every *second* variable in the range (skipping "after"
measurements) 

Next: subset.frame() - before I do the obvious: Is there a simple way
of getting R to search a frame *before* the global environment?

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


R-alpha: User friendly functions
Peter Dalgaard BSA