If you have a data frame "df" with a column "JT"

Try this one:
str <- "df$JT == 12"

fun<-function(str){b<-eval(parse(text=str))
return(b)}

fun(str)

On Mon, Sep 17, 2012 at 11:57 AM, Christof Kluß <ckl...@email.uni-kiel.de>wrote:

> Hi
>
> I would like to have something like
>
> str <- "df$JT == 12"
>
> fun <- function(df) {
>
>   b <- eval(parse(str))
>
>   return(b)
> }
>
> but for performance "eval(parse(a))" should not be evaluated at each
> function call, but should work as
>
> fun <- function(df) {
>
>   b <- df$JT == 12
>
>   return(b)
> }
>
> Do you have an idea how I can implement this?
>
> Thx
> Christof
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to