The Magic of Substitute and Deparse by Guangming Lang ~1 min read October 5, 2014 Categories r The R functions substitute() and deparse() are very interesting and here’s why. foo1 = function(a, ...) { arg = deparse(substitute(a)) dots = substitute(list(...))[-1] c(arg, sapply(dots, deparse)) } foo2 = function(a, ...) { arg = deparse(substitute(a)) dots = list(...) c(arg, sapply(dots, deparse)) } x = 1; y = 2; z = 3 foo1(x, y, z) ## [1] "x" "y" "z" foo2(x, y, z) ## [1] "x" "2" "3" You can learn more about them here and here. Share Tweet LinkedIn Reddit Previous The setwd Function in R Next When Does A Flexible Model Beat An Inflexible One and Vice Versa