R if statement

R Tutorial – We shall learn about R if statement and how does this help in decision making with examples and pictures.

R if statement

R if statement does help in executing a set of statements based on a condition. If the condition provided to the if statement is true, then the statements in the if statement block are executed, else not.

Following is a flow diagram depicting the flow of execution around and in an if statement.

R if statement

Syntax

if(boolean_expression){
    statement1
    statement2  . . .
    statementN
}

The boolean_expression is any expression that evaluates to a boolean value. And if the boolean value = TRUE, execution flow enters the block of if statement, else it skips the statements’ execution in the block

 

Example

 

Conclusion :

In this R Tutorial, we learnt about R if statement, its Syntax and how does this if statement help in decision making in R Programming language with example program.