Get the List of Arguments of a Function in R Programming – args() Function

args() function in R Language is used to get the required arguments by a function. It takes function name as arguments and returns the arguments that are required by that function.

Syntax: args(name)

Parameters:
name: Function name

Returns:

  • For a closure: Formal Argument list but with NULL body
  • For a Primitive Function: A closure with usage and a NULL body
  • For a non-function: NULL in case of not a function.

Example 1:



filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to get arguments of a function
  
# Calling args() Function
args(append)
args(sin)
args(paste)

chevron_right


Output:

function (x, values, after = length(x)) 
NULL
function (x) 
NULL
function (..., sep = " ", collapse = NULL) 
NULL

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to get arguments of a function
  
# Calling args() Function
args(1)
args(10)

chevron_right


Output:

NULL
NULL

The above code returns NULL because the names passed to args() function are not actual functions.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.