Generic rule engine for R