search for: pick_arg

Displaying 2 results from an estimated 2 matches for "pick_arg".

2025 Jan 09
1
Extracting specific arguments from "..."
...# only `a` is forced #> f3 1 sqrt(4) # only `a` is forced #> f4 cos(0) sqrt(4) # none of the arguments are forced ``` Also, here's a possible way to adapt Hadley Wickham's approach so that it takes the name of the argument as a string, though it does lose the elegance: ``` pick_arg <- function(nm) { as.function(c( setNames(alist(. = , . = ), c(nm, "...")), as.symbol(nm) )) } z <- "a" f5 <- function(...) { pick_arg(z)(...) } f5(b = 2, a = 1, c = 3) #> [1] 1 ``` Regards, Ian ____ Ian Farm, Laboratory Manager University of Maine Ag...
2025 Jan 08
1
Extracting specific arguments from "..."
That's very nice, Hadley. Simple and clean. Never would have thought of it myself. As usual, however, in the course of my churnings, I have a further complication to add. But first ... **TO ALL**: Feel free to ignore the following, as I'm just fooling around here and don't want to waste your time with my stupid stuff. Anyway, the complication is motivated by the use of formals() or