如果是构建块

时间:2013-09-02 08:07:31

标签: r if-statement

R中是否有等效的构建块

if ($a > $b) {
    echo "a is bigger than b";
} elseif ($a == $b) {
    echo "a is equal to b";
} else {
    echo "a is smaller than b";
}

来自PHP还是Java?

1 个答案:

答案 0 :(得分:3)

这不是惯用的,但答案是肯定的:

if (a > b) {
  cat("a is bigger than b")
} else if (a == b) {
  cat("a is equal to b")
} else {
  cat("a is smaller than b")
}