[R] argument names inside a function?
    Ed Siefker 
    ebs15242 at gmail.com
       
    Sat Mar 24 22:28:48 CET 2012
    
    
  
Thanks, deparse(substitute()) does exactly what I want.
On Sat, Mar 24, 2012 at 4:20 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> Can you be a little more concrete?
>
> If you want the form of the expression given (rather than its value),
> deparse(substitute()) will work:
>
> fnc1 <- function(x){ deparse(substitute(x))}
>
> fnc1(3) # 3
>
> fnc1(x) # "x"
>
> fnc1(x + 4) # "x+4"
>
> If you are passing them through the ... argument, you can coerce that
> to a list and use the names() attribute.
>
> If you want to reconstruct the exact call (e.g., for a modelling
> function), match.call() will do it.
>
> Hope this helps,
> Michael
>
    
    
More information about the R-help
mailing list