R 嵌套 If
嵌套 If 语句
你也可以在 if
语句中包含 if
语句,这被称为嵌套 if 语句。
实例
x <- 41 if (x > 10) { print("Above ten") if (x > 20) { print("and also above 20!") } else { print("but not above 20.") } } else { print("below 10.") }
你也可以在 if
语句中包含 if
语句,这被称为嵌套 if 语句。
x <- 41 if (x > 10) { print("Above ten") if (x > 20) { print("and also above 20!") } else { print("but not above 20.") } } else { print("below 10.") }