From p.dalgaard@kubism.ku.dk  Mon Apr 14 23:59:23 1997
From: p.dalgaard@kubism.ku.dk (Peter Dalgaard BSA)
Date: 15 Apr 1997 00:59:23 +0200
Subject: R-alpha: select.frame
Message-ID: <x2ragd9po4.fsf@bush.kubism.ku.dk>

Here's the select.frame() function I babbled about before. Suggestions
about coding style, etc., are welcome, I feel a bit green at this.

select.frame<-
function (dfr, ...) 
{
        subst.exp <- function(e) {
                for (i in 2:length(e)) {
                        ei <- e[[i]]
                        if (is.call(ei)) 
                                e[[i]] <- subst.exp(ei)
                        else {
                                n <- match(as.character(ei), nm)
                                if (!is.na(n)) 
                                 e[[i]] <- n
                        }
                }
                e
        }
        nm <- names(dfr)
        e <- as.call(c(as.name("c"), expression(...)))
        dfr[, eval(subst.exp(e))]
}


-- 
   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: select.frame
Peter Dalgaard BSA