recreate(substitute(A + ~B*C))
foo <- function(x, ...) recreate(substitute(list(...)))
foo(arg1 = 3, arg2 = A + ~B*C)
df <- data.frame(A = 1, B = 2, C = 3, Y = 4)
# substitute from the global environment
# the result is the builtin C() function
res <- recreate(substitute(C))
is.function(res) # TRUE
# search first within the column name space from df
recreate(substitute(C), colnames(df))
# "C"
# necessity well recognized
recreate(substitute(A <- B))
# but sufficiency is flipped
recreate(substitute(A -> B))
# more complex SOP expressions are still recovered
recreate(substitute(A + ~B*C -> Y))
Run the code above in your browser using DataLab