On Nov 30, 2010, at 9:54 PM, randomcz wrote:
Hi guys, How to pass an operator to a function. For example, test <- function(a, ">", b) { return(a>b) #the operator is passed as an argument }
I think you have just requested the definition of do.call() although you infix positioning is a bit non-standard:
?do.call > do_this <- function(a, fn=">", b) {do.call(fn, list(a , b))} > do_this(a=1, b=4) [1] FALSE > do_this(a=1, b=0) [1] TRUE
-- David Winsemius, MD West Hartford, CT ______________________________________________ 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.