Arguments are the parameters provided to a function to perform operations in a programming language. In R programming, we can use as many arguments as we want and are separated by a comma. There is no limit on the number of arguments in a function in R. In this article, we’ll discuss different ways of adding arguments in a function in R programming.
Adding Arguments in R
We can pass an argument to a function while calling the function by simply giving the value as an argument inside the parenthesis. Below is an implementation of a function with a single argument.
 "number is divisible by 5"  "number is not divisible by 5"  "number is divisible by 5"
Adding Multiple Arguments in R
A function in R programming can have multiple arguments too. Below is an implementation of a function with multiple arguments.
 "7 is not divisible by 3"  "36 is divisible by 6"  "9 is not divisible by 2"
Adding Default Value in R
Default value in a function is a value that is not required to specify each time the function is called. If the value is passed by the user, then the user-defined value is used by the function otherwise, the default value is used. Below is an implementation of function with default value.
 "10 is divisible by 5"  "12 is divisible by 3"
Dots argument (…) is also known as ellipsis which allows the function to take an undefined number of arguments. It allows the function to take an arbitrary number of arguments. Below is an example of a function with an arbitrary number of arguments.
 "5 1 0+6i TRUE GeeksForGeeks Dots operator"
Function as Argument
In R programming, functions can be passed to another functions as arguments. Below is an implementation of function as an argument.
 55  0.2153183
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.