How can I get the formals (arguments) from a call object? formals() only seems to work with functions.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, a call does not have formals, only actual arguments… The difference being that a function like
foo <- function(x, y, ..., z=42)can be called with actual arguments likefoo(42, bar=13).…But getting the arguments can be done like this:
…on the other hand, you can usually (not always) find the actual function and find the formals for it:
Here you’d need to add some error handling if the function can’t be found (as with the call to
fooabove)…