Skip to content

question about deparse(substitute(...))

3 messages · Sean Zhang, William Dunlap, Gabor Grothendieck

#
One way is:
   > f <- function(...) lapply(substitute(placeholderFunction(...))[-1],
deparse)
   > f(x, log(y), (function(a){a+a^2/2+a^3/6})(z))
   [[1]]
   [1] "x"

   [[2]]
   [1] "log(y)"

   [[3]]
   [1] "(function(a) {"       
   [2] "    a + a^2/2 + a^3/6"
   [3] "})(z)"                

Use paste(collapse="\n",s) or s[1] on
deparse's output if you require one
string per input.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
#
On Thu, Jan 13, 2011 at 7:36 PM, Sean Zhang <seanecon at gmail.com> wrote:
Try this:
[1] "x" "y" "z"

You could consider replacing sapply with lapply since it will return a
list of vectors if the arguments are complex -- so that would
consistently return a list.