Lessons
- Relational Operators in R
- Logical Operators in R
- Conditional Statements in R
- For Loop in R Programming
- While and Repeat Loop in R Programming
- Functions in R Programming
- Creating Functions in R
- Apply Functions in R
- Importing Data from External Data Sources in R
- Importing Data Using read.csv in R
- Import Data using read.table in R
- Importing Data Using data.table – fread in R
- Importing Data from Excel in R
- Using XLConnect in R Programming
- Importing Data from a Database in R
- SQL Queries from R
- Importing Data from Web in R
Conditional Statements in R
In programming, we often want to check a conditional statement and then do something if the condition is met and do something else if the condition is not met. This is done using the If conditions.
There are two general forms of decision making structures found in most of the programming languages:
if statement
if(BooleanExpression)
statement;
if(BooleanExpression) {
statement1;
statement2;
...
}
If the BoolenExpression is true, then the statements will be executed.
if...else statement
statement or block 1
else
statement or block 2
Examples
This content is for paid members only.
Join our membership for lifelong unlimited access to all our data science learning content and resources.