I have a function that build a logical condition dynamically according to parameter (that determines the predicate length). Here's the code:
predicate <- function(pred.size){
predicate.result <- ""
for(s in 1:pred.size){
predicate.result <- paste (predicate.result,data.clean.eval[j,top.pred.size.predictions[[s]][1]] , " == TRUE ", sep = " ")
if (!s==pred.size) predicate.result <- paste (predicate.result, " OR ")
}
if (paste(predicate.result)) return TRUE else RETURN FALSE
}
however, pred.result return a string:
predicate.result [1] " FALSE == TRUE OR FALSE == TRUE " and when coming to test the condition if (paste(predicate.result)) return TRUE else RETURN FALSE R return error: Error: unexpected numeric constant in "if (paste(predicate.result)) return TRUE"
any idea how to test that predicate and make this function return TRUE/FALSE ?