OneBite.Dev - Coding blog in a bite size

check if two variable is not equal in R

Code snippet on how to check if two variable is not equal in R

# Assign the variables
x <- 4
y <- 5

# Check is x is not equal to y
if(x != y) {
  print("x and y are not equal")
}

The code above first creates two variables ‘x’ and ‘y’ and assigns them a value: 4 and 5. Then an ‘if’ statement is used to evaluate if the two variables are NOT equal. The statement says if ‘x’ does not equal ‘y’ then execute the code inside the curly brackets. The code inside the braces is to print the message “x and y are not equal.” The output of the code is the message when it is executed.

r