#I have a dataframe called "tests" that contain "character expressions".  These
characters are rules that use data from within another dataframe.  Is there
any way within R I can access the rules in the dataframe called tests, and
then "evaluate" these "rules"?



#An example may better explain what I am trying to accomplish:



tests <- data.frame(matrix(data=c("info$country == 'Greenland'", "info$age
> 50"), nrow=2, ncol=1))

names(tests) <- "rule"



info <- data.frame(matrix(data=NA, nrow=5, ncol=3))

names(info) <- c("first", "country", "age")

info$name <- c("Mary", "Paul", "Robert", "John", "Ivan")

info$country <- c("GReenland", "Iceland", "Ireland", "Greenland",
"Greenland")

info$age <- c(30, 55, 66, 79, 80)



#e.g. for

"info$country == 'Greenland'"



#I want:

info$country == 'Greenland'

[1] FALSE FALSE FALSE  TRUE  TRUE

#e.g.
info$country == 'Greenland'

info$age > 50



#I tried this, but it does not "work":

eval(tests$rule[1])

        [[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