[R] Obtaining names of further arguments ('...')
Arne Henningsen
ahenningsen at email.uni-kiel.de
Sun Dec 9 22:30:31 CET 2007
On Sunday 09 December 2007 15:09, Duncan Murdoch wrote
> [...] To get what you
> want, use match.call() to get the call in unevaluated form, and then
> process it. For example,
>
> f2 <- function( ... ) {
> call <- match.call()
> args <- as.list(call)[-1]
> unlist(lapply(args, deparse))
> }
>
> > f2(x1, x2, x3)
>
> [1] "x1" "x2" "x3"
>
> > f2( x1 + x3, mean(x2), 3)
>
> [1] "x1 + x3" "mean(x2)" "3"
>
> If your function has arguments other than ... you'll need a bit more
> work to remove them. They'll end up as the names of the values in the
> final result.
This does exactly what I wanted!
@Duncan: Thank you very much for your quick and helpful answer!
Best wishes,
Arne
--
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445 or +49-4349-914871
Fax: +49-431-880 1397
ahenningsen at agric-econ.uni-kiel.de
http://www.uni-kiel.de/agrarpol/ahenningsen/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20071209/9b82d8ba/attachment.bin
More information about the R-help
mailing list