[R] Language element manipulation

Stuart Luppescu s-luppescu at uchicago.edu
Fri Jul 28 04:43:31 CEST 2000

I am very confused about this. I want to convert a string to a name so I can
use it to extract an element of a data frame using `$'. Here is my
(non-working) code:

do.graph <- function (meas)
    fn <- paste("a", meas, ".dat", sep='')
    themeas <- read.table(fn, header=F)
    ameas <- as.name(paste("a", meas, sep=''))
    names(themeas) <- c("xpos", paste("a", meas, sep=''))
    meassum <- summary(themeas$ameas[themeas$xpos==1])
So, when this function is called with the argument ``infl'' the second column
will be named ``ainfl''. In the last line I want to extract the column called
``ainfl'' from the data frame ``themeas''. But this is what happens:

> themeas$ameas

Just grabbing at straws here:

Error: attempt to apply non-function

Can someone wise me up about this?
Stuart Luppescu         -=-=-  University of Chicago
ºÍʸ ¤ÈÃÒÆàÈþ¤ÎÉã(EUC)  -=-=-  s-luppescu at uchicago.edu
PGP public key: www.consortium-chicago.org/people/sl/pubkey.asc
       ICQ #21172047  AIM: psycho7070
        "She's about as smart as bait."
>> Sent on 27-Jul-2000 at 
r-help 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-help-request at stat.math.ethz.ch

More information about the R-help mailing list