Writing functions with multiple arguments and use of default values
The input of a function is known as an argument. Often, you may need to write a customized function with multiple inputs. In this recipe, you will learn to use multiple arguments and the default values of the argument.
Getting ready
In this recipe, you will write a new customized function that will take more than one input, and at least one of them will contain default values. Specifically, in this recipe, the function will take one numeric vector as input and another character input with a default value. The objective of this function is to calculate descriptive statistics of the numeric vector, and another character input will specify the type of descriptive statistics, either classical or robust.
The classical descriptive statistics here refers to mean and standard deviation, whereas the robust counterpart refers to median and median absolute deviation (MAD).
The input numeric vector is given as follows:
V1 <- c(3,...