You can use match.call to extract the arguments:
myFunc <- function( x ) { x <- match.call()$x print(class(x)) print(typeof(x)) print(mode(x)) print(storage.mode(x)) print(is.expression(x)) print(is.call(x)) if (is.call(x)) print(x[[1]]) } myFunc({x = 5; print("a")}) myFunc(expression(x)) x <- factor(1) myFunc(x) myFunc(1)
Perhaps I need to say that { is a function in R, so {...} no more than call .
Updated: why x not function , but { - function :
f <- function(x) { x <- match.call()$x print(eval(x[[1]])) print(is.function(eval(x[[1]]))) } f({1})
source share