[R] Deparsing '...'

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Mar 2 18:18:27 CET 2006


f <- function(...) as.character(match.call())[-1]
> f(x,a,b,c*d)
[1] "x"     "a"     "b"     "c * d"

On Thu, 2 Mar 2006, Matthew Dowle wrote:

>
> Hi,
>
> The following function works, but is there a neater way to write it?
>
> f = function(x,...)
> {
>    # return a character vector of the arguments passed in after 'x'
>    gsub("
> ","",unlist(strsplit(deparse(substitute(list(...))),"[(,)]")))[-1]
> }
>
>> f(x,a,b,c*d)
> [1] "a"   "b"   "c*d"
>>
>
> Thanks.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list