Hi, all. I'm trying to automate some regression operations in R but am
confused about how to evaluate expressoins that are expressed as
character strings. For example:
y <- ifelse (rnorm(10)>0, 1, 0)
sex <- rnorm(10)
age <- rnorm(10)
test <- as.data.frame (cbind (y, sex, age))
# this works fi
Try this:
e <- expression(glm(y ~ age))
eval(e)
or this:
chr <- "glm(y ~ age)"
eval(parse(text = chr))
On 5/2/06, Andrew Gelman <[EMAIL PROTECTED]> wrote:
> Hi, all. I'm trying to automate some regression operations in R but am
> confused about how to evaluate expressoins that are expressed as
://www.med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: "Andrew Gelman" <[EMAIL PROTECTED]>
To:
Sent: Tuesday, May 02, 2006 5:12 PM
Subject: [R] evaluation of expressions
> Hi, all. I'm trying to