use if conditional statement in R
Code snippet on how to use if conditional statement in R
if(x < y)
z <- x
else
z <- y
``
This code uses an if conditional statement to compare two variables, x and y. The first part of the statement, "if(x < y)," checks if x is less than y. If that condition is met then the code moves to the next line, "z <- x," which assigns x to a new variable, z. The else statement, "else z <- y," is executed if the if statement is not met and assigns y instead to z. In the end, if x is less than y then z will be set to x, and if x is not less than y then z will be set to y.