A function in R is a set of instructions for a certain task to complete. The function could take any input you define, or it could work without any input. In this recipe, you will learn how to write a function and you will learn about the components of a function.
Let’s say you want to calculate the ratio of the standard deviation and mean of a given vector of five numbers. The input values are (3, 7, 2, 6, 9). To give these five values as an input to a function, you need to create a vector that contains these numbers as follows:
V1 <- c(3, 7, 2, 6, 9)