Open In App
Related Articles

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

Improve Article
Improve
Save Article
Save
Like Article
Like

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:




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


Output:

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

Example 2:




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


Output:

NULL
NULL

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 12 Jun, 2020
Like Article
Save Article
Previous
Next
Similar Reads