use a conditional to check greater than number in R
Code snippet on how to use a conditional to check greater than number in R
if (x > 5) {
print("x is greater than 5!")
} else {
print("x is not greater than 5!")
}
This code will check if the value of the variable “x” is greater than 5. The code first checks the if-clause, where the condition “x > 5” is evaluated. If this condition is true, i.e. x is greater than 5, the code inside the first part of the conditional between {} braces will be executed and it will print “x is greater than 5!“. On the other hand, if the condition is false, i.e. x is not greater than 5, the code inside the second part of the conditional will be executed and it will print “x is not greater than 5!“.