Decisions

if and ifelse.

if is for one value. ifelse is for a vector.

Goal

Label busy vs quiet.

units <- 12
if (units >= 10) {
  print("busy")
} else {
  print("quiet")
}
city <- "Mombasa"
if (city == "Nairobi") {
  print("capital")
} else if (city == "Mombasa") {
  print("coast")
} else {
  print("other")
}
units <- c(12, 8, 5)
print(ifelse(units >= 10, "busy", "quiet"))
print(ifelse(c("Nairobi", "Kisumu") == "Nairobi", "capital", "other"))