[R] Extracting specific arguments from "..."

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sun Jan 5 18:59:22 CET 2025


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



More information about the R-help mailing list