Conditional Statements

✅ Conditionals let your code make decisions. With if, else if, and else, you can control which blocks of code run based on whether a condition is TRUE or FALSE.

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.