A function argument is an input value supplied inside a function call. Arguments tell R what data or values a function should use before it produces a return value. section 13.7
When working with function arguments:
- Place one or more inputs inside parentheses, separating multiple arguments with commas. section 13.7
- Match the required arguments to the function’s expected inputs; omitting one can produce an error. section 13.7
Supplying arguments to a custom function
The custom gini.est() function requires a, b, and c. Calling gini.est(.05, .18) fails because c is missing; calling gini.est(.05, .18, .44) returns 0.522. section 13.7
r_to_rsquared <- function(r) {
rsquared <- r^2
return(rsquared)
}
See a user-defined function that accepts r as its argument and returns its squared value. section 13.7




