标准写法

控制流 / 条件语句 / if/else 语句

latitude <- sample(-90:90, 1)

# Checked top down: the first true branch runs
if (latitude == 0) {
  location <- "Equator"
} else if (latitude < 0) {
  location <- "Southern Hemisphere"
} else {
  location <- "Northern Hemisphere"
}

cat("latitude =", latitude, "\n")
cat("location =", location, "\n")