R: if statement

Profile picture for user devanshi.srivastava
Submitted by devanshi.srivastava on

As in other programming languages if a statement is very useful so it can also be useful in R. This statement is the type of decision-making statement in R. 

If the given condition is true, then the set of statements will get executed but if the condition is a false set of statements will not get executed. 


if (condition) {
   set of statements 


R If condition


a <-4
if( a%%2==0 )#condition
  print("Even Number")  # Statement


[1] "Even Number"