Worksheet 5 - User-defined Functions

User Defined Functions

  1. Describe the components and arguments of the following function.
largest <- function(x,y,z){
  a <- c(x,y,z)
  l <- which.max(a)
  paste(a[l],"is the largest number")
}
  1. Create and test a function that takes in two vectors and determines which is the longer vector.