Klaus
Klaus

Reputation: 2056

If else building block

Is there an equivalent building block in R for

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";
}

from PHP or Java?

Upvotes: 0

Views: 198

Answers (1)

user2739139
user2739139

Reputation: 46

It's not idiomatic but the answer is yes:

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")
}

Upvotes: 3

Related Questions