Conditional Statements
The if
Statement
Runs a block of code only if the condition is TRUE
.
The else
Statement
Use else
to run code when the if
condition is FALSE
.
The else if
Statement
Use else if
to check additional conditions.
Logical Operators
You can combine conditions using &
(and), |
(or), and !
(not).
Nested Conditional Statements
You can nest conditionals inside each other.
Common Errors
Some frequent mistakes when writing conditionals in R.