[R] getting arg names in function calls?

Spencer Graves spencer.graves at structuremonitoring.com
Tue Apr 8 00:05:20 CEST 2014

       How can I convert "plot(0, 1)" into "plot(x=0, y=1)"?

       More generally, how can I get argument names assigned to function 
calls in "language" objects?


tstFn <- function()plot(0, 1)
bo <- body(tstFn)

tstFnxy <- function()plot(x=0, y=1)
boxy <- body(tstFnxy)

       Is there a function that will modify "bo" to match "boxy"?

       My current solution requires me to know the names of the 
arguments for "plot" (in this example).  I'd prefer a more general 


p.s.  I'm trying to create an animation by repeatedly calling a function 
that contains something like text(0, 1, "abc").  By computing on the 
language object 'text(0, 1, "abc")', I can call text(0, 1, 'a') the 
first time, text(0, 1, 'ab') the second, and text(0, 1, 'abc') the 
third.  The function will be more general if I can get the names of the 
arguments as just described.

More information about the R-help mailing list