The & symbol (and) is a logical operator, and is used to combine conditional statements:
Test if a is greater than b, AND if c is greater than a:
a <- 200
b <- 33
c <- 500
if (a > b & c > a) {
print("Both conditions are true")
}
Try it Yourself »
The |
symbol (or) is a logical operator, and is used to combine conditional statements:
Test if a is greater than b, or if c is greater than a:
a <- 200
b <- 33
c <- 500
if (a > b | a > c) {
print("At least one of the conditions is true")
}
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!