Javatpoint Logo
Javatpoint Logo

R if Statement

The if statement consists of the Boolean expressions followed by one or more statements. The if statement is the simplest decision-making statement which helps us to take a decision on the basis of the condition.

The if statement is a conditional programming statement which performs the function and displays the information if it is proved true.

The block of code inside the if statement will be executed only when the boolean expression evaluates to be true. If the statement evaluates false, then the code which is mentioned after the condition will run.

The syntax of if statement in R is as follows:

Flow Chart

R If Statement

Let see some examples to understand how if statements work and perform a certain task in R.

Example 1

Output:

R If Statement

Example 2

Output:

R If Statement

Example 3

Output:

R If Statement

Example 4

Output:

R If Statement

Example 5

Output:

R If Statement
Next TopicIf-else statement




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA