Introduction

In this exercise, we will practice modifying and writing functions.

Part A

  1. Look again at your findTallest() function. How would we use this to find the age of the oldest person in the room? Write a function findOldest() that does performs this task.

  2. Modify your findTallest() function to find the shortest person in the room. Name this new function findShortest().

  3. Use one of your functions to find the tallest or shortest height from the vector theirHeights <- c(63, 58, NA, 72, 65). What happens? Modify your function to handle this missing data. HINT: There are several methods for this. If you wish to use an if/else statement, consider using is.na(). Alternatively, google “handling missing values R” and see what solutions you can find.

Part B

Write a function that will take in 4 numbers and return them in order from least to greatest. SHELL:

mySort <- function(numbers){
    
    ## your code to sort the numbers goes here. 
    
    return(numbers)
}