formula argument evaluation
On 12/04/2016 11:24, Adrian Du?a wrote:
I have a simple function such as:
foo <- function(x) {
call <- lapply(match.call(), deparse)
testit <- capture.output(tryCatch(eval(x), error = function(e) e))
if (grepl("Error", testit)) {
return(call$x)
}
}
and I would like to detect a formula when x is not an object:
# this works
foo(A + B)
[1] "A + B" # but this doesn't
foo(A + B => C)
Error: unexpected '=' in "foo(A + B =" Can I prevent it from evaluating the "=" sign? The addition sign "+" hasn't been evaluated, and I was hoping the "=" would not get evaluated either. The "=>" sign is important for other purposes, not related to this example. Thank you in advance, Adrian -- Adrian Dusa University of Bucharest Romanian Social Data Archive Soseaua Panduri nr.90 050663 Bucharest sector 5 Romania [[alternative HTML version deleted]]
Did you mean > foo (A + B >= C) ??