Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
Of Andreas Leha
Sent: Friday, November 01, 2013 2:50 PM
To: r-help at stat.math.ethz.ch
Subject: Re: [R] quickly extract response from formula
Hi David,
thanks for your quick answer!
David Winsemius <dwinsemius at comcast.net> writes:
On Oct 31, 2013, at 1:27 PM, Andreas Leha wrote:
Hi all,
what is the recommended way to quickly (and without much burden on the
memory) extract the response from a formula?
If you want its expression value its just form[[2]]
If you wnat it evaluated in the environment of a dataframe then this should be fairly
x <- stats::runif(20)
y <- stats::runif(20)
dfrm <- data.frame(x=x,y=y)
extractResponse <- function(frm, dat) { resp <- frm[[2]]; print(resp) # that's optional
fdat <- eval(resp,
envir=dat); return(fdat) }
This is what I'll be using. Thanks again!
[...]
Regards,
Andreas