Displaying 5 results from an estimated 5 matches for "ycdgn3i".
Did you mean:
ycdgn3y
2025 Jan 06
1
Extracting specific arguments from "..."
I think Bert Gunter is right, but do you want partial matches (not found by match), and how robust do you want the code to be?
f <- function(?)
{ pos <- match('a', ...names())
if (is.na(pos))
stop("a is required.")
?elt(pos)
}
Incidentally, what is the best way to extract the expression without evaluating it?
g <- function(...)
{ pos <-
2025 Jan 06
1
Extracting specific arguments from "..."
Thanks Jorgen.
I thought your approach to getting the argument expressions was clever, but
somewhat convoluted. I think the usual simple way is to use match.call()
(or sys.call() )to get the unevaluated argument expressions; e.g. ...
f <- function(...){
match.call()
}
> f(a = 'red', b = sin(zzz))
f(a = "red", b = sin(zzz))
The return value is an object of class call
2025 Jan 06
2
Extracting specific arguments from "..."
Bert and other on this Chain,
The original question asked by Bert Gunter, highlights one of my long standing wishes. Perhaps my wish has already been fulfilled (if it has, please let me know where I can look of fulfill my wish), if it hasn't perhaps someone can grant me my wish.
I have tried to understand how to write a function (beyond a basic function), get values of the parameters, and
2025 Jan 07
1
Extracting specific arguments from "..."
It is a pretty tricky topic, but IMO Advanced R [1] steps you through it systematically... you just have to be prepared to follow along in R with the examples as you read it. In particular, the chapter on Functions goes through this.
The subtleties of how base R gives you control over these topics is what lead to the tidyverse creating new packages to build such function interfaces. Manipulating
2025 Jan 07
1
Extracting specific arguments from "..."
Jeff:
Would you care to offer an example of:
"String literals are surprisingly simple alternatives that don't bite you
in the butt nearly so often as NSE does."
"No" is a perfectly acceptable answer.
I would generally agree with you about NSE, but my original query was
motivated by something simple. I like to use lattice graphics when I fool
around with graphing data, as