Reputation: 1771
I have not found what I was looking for on Google and Stack. I also looked at ?help
function documentation but got no real answer so I will ask my question here : Is there a function that return the arguments (and their descriptions) of a function?
I think an example is the best way to add some clarity to my question. I would like to know if I can do something along the line of :
some_function(fct = print(), arg_number = 1)
Where the output would be the first argument of the print()
function :
"x an object used to select a method."
Even a function returning a list of all the arguments could probably do the job.
Thank you
Upvotes: 1
Views: 224
Reputation: 44867
To get the help descriptions of each argument, you need to look at the help pages. This is complicated, but RStudio does it. You could look through their source on https://github.com/rstudio/rstudio, or look at the R sources to see how the check code does things. The function to look at in R is tools::checkDocFiles
.
Upvotes: 0
Reputation: 4233
There is a function that returns arguments of a function (and their default values). It's called formals
. From its help page:
Description. Get or set the formal arguments of a function
It is also convenient to use View
to inspect function definitions:
View(function_name)
Upvotes: 1