[R] Deparsing '...'

Matthew Dowle mdowle at concordiafunds.com
Thu Mar 2 18:13:50 CET 2006


That's much neater, thanks.

> -----Original Message-----
> From: pd at pubhealth.ku.dk [mailto:pd at pubhealth.ku.dk] On 
> Behalf Of Peter Dalgaard
> Sent: 02 March 2006 16:59
> To: Matthew Dowle
> Cc: 'r-help at stat.math.ethz.ch'
> Subject: Re: [R] Deparsing '...'
> 
> 
> Matthew Dowle <mdowle at concordiafunds.com> writes:
> 
> > 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"
> > > 
> 
> 
> > f <- function(x,...)as.character(match.call(expand.dots=FALSE)$...)
> >  f(x,a,b,c*d)
> [1] "a"     "b"     "c * d"
> 
> or maybe
> 
> f  <- function(x,...)
>   sapply(match.call(expand.dots=FALSE)$..., deparse, backtick=TRUE)
> 
> 
> 
> 
> -- 
>    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark          Ph:  
> (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: 
> (+45) 35327907
>




More information about the R-help mailing list