Re: [R] Deparsing '...'

From: Matthew Dowle <mdowle_at_concordiafunds.com>
Date: Fri 03 Mar 2006 - 04:40:26 EST

That's even neater. But when its called from within another function, this happens, see below. I was planning to call f something like 'getdots' and use it in several functions that need to do this.

> f <- function(...) as.character(match.call())[-1]
> f(a,b,c)
[1] "a" "b" "c"
> g = function(x,...) f(...)
> g(x,a,b,c)
[1] "..1" "..2" "..3"

> -----Original Message-----
> From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk]
> Sent: 02 March 2006 17:18
> To: Matthew Dowle
> Cc: 'r-help@stat.math.ethz.ch'
> Subject: Re: [R] Deparsing '...'
>
>
> 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@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
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Mar 03 04:53:49 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 06:08:21 EST