Please use D2L to turn in both the HTML output and your R Markdown file in.

Q1. Code Debugging (10 pts)

Consider the following function which contains a few errors. Fix the function so that the four function calls below return the correct values.

TimeofDay <- function(time.in){
  # function to map time in military time (0 - 24)
  # to defined categories for day
  # ARGS: time.in, as 'HH:MM' as a string
  # Returns: "05:00" to "11:59" - 'Morning'
  #          "12:00" to "16:59" - 'Afternoon'
  #          "17:00" to "20:59" - 'Evening'
  #          "21:00" to "04:59" - 'Night'
  hour <- substr(time.in,1,3)
  minute <- substr(time.in,3,4)
  if (hour > 5 & <= 12){
    return("Morning")
  } else if (hour >= 12 & hour < 17 ){
    return(Afternoon)
  } else if (hour >= 12 & hour < 21) {
    return('Evening')
  } else if (hour >= 21 & hour < 5){
    return('Night')
  }
}
TimeofDay('08:14')
TimeofDay('12:00')
TimeofDay('18:34')
TimeofDay('02:53')
## Error: <text>:11:18: unexpected '<='
## 10:   minute <- substr(time.in,3,4)
## 11:   if (hour > 5 & <=
##                      ^