On Sat, Jun 19, 2010 at 4:56 AM, Johannes Huesing <[email protected]> wrote:
> A rule would be a data structure containing the ID of the rule, the
> rule in human readable language, an expression evaluating variables
> within the environment of the appropriate data frame (and resolving to
> a logical vector), possibly the data frame itself, and the query
> message (possibly as an sprintf expression). The data structure may be
> an S4 object or a list. In our current workflow, we manage the
> validation rules using a spreadsheet, and import them into a
> competitor's analysis software.
>
> I could pass
>
> function(df) with(df, (vsstresn < 30 | vsstresn > 130) & vstestcd == "HR")
Another possibility would be to use an sql statement or fragment so if
you passed this sql fragment:
> fragment <- "(vsstresn < 30 or vsstresn > 130) and vstestcd = 'HR'"
>
> # then your program would run this code:
>
> df <- data.frame(vsstresn = seq(10, 200, 10), vstestcd = rep(c("HR", "RH"),
> c(16, 4)))
> library(sqldf)
> sqldf(paste("select * from df where", fragment))
vsstresn vstestcd
1 10 HR
2 20 HR
3 140 HR
4 150 HR
5 160 HR
______________________________________________
[email protected] 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.