Section 22 Function: Arguments

22.1 Formal argument

  • Arguments that must be supplied with appropriate values while calling the function.

22.2 Default argument value

  • Arguments with default value will be considered if no value is given while calling the function.

22.3 Argument matching

  • Matched by argument names

  • Matched by argument positions

  • Matched by a mix of argument names and positions

  • Partial matching is possible

  • Order of argument matching

    • Check for the exact match
    • Check for the partial match
    • Check for the positional match

22.4 The ... argument

  • A way to provide further arguments to or from other functions
?cat
?rep
?seq
?paste
?mean
  • Advantage of ... arguments
    • to extend the functionality of another function
    • when the number of arguments passed to the function cannot be known in advance
    • arguments comming after the ... must be named explicitly and cannot be partially matched or matched positionally