[R] Extracting specific arguments from "..."
Iris Simmons
|kw@|mmo @end|ng |rom gm@||@com
Sun Jan 5 19:15:55 CET 2025
I would use two because it does not force the evaluation of the other
arguments in the ... list.
On Sun, Jan 5, 2025, 13:00 Bert Gunter <bgunter.4567 using gmail.com> wrote:
> Consider:
>
> f1 <- function(...){
> one <- list(...)[['a']]
> two <- ...elt(match('a', ...names()))
> c(one, two)
> }
> ## Here "..." is an argument list with "a" somewhere in it, but in an
> unknown position.
>
> > f1(b=5, a = 2, c=7)
> [1] 2 2
>
> Which is better for extracting a specific named argument, one<- or
> two<- ? Or a third alternative that is better than both?
> Comments and critiques welcome.
>
> Cheers,
> Bert
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list