Concept Flow - Comparison operators
Start
Evaluate Left Value
Evaluate Right Value
Apply Comparison Operator
Result: TRUE or FALSE
End
The program compares two values using a comparison operator and produces TRUE or FALSE as the result.
a <- 5 b <- 3 result <- a > b print(result)
| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Assign a | a <- 5 | a = 5 |
| 2 | Assign b | b <- 3 | b = 3 |
| 3 | Compare a > b | 5 > 3 | TRUE |
| 4 | Assign result | result <- TRUE | result = TRUE |
| 5 | Print result | print(result) | [1] TRUE |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| a | undefined | 5 | 5 | 5 | 5 | 5 |
| b | undefined | undefined | 3 | 3 | 3 | 3 |
| result | undefined | undefined | undefined | undefined | TRUE | TRUE |
Comparison operators in R compare two values and return TRUE or FALSE. Common operators: >, <, >=, <=, ==, != Syntax example: result <- a > b Result is logical (TRUE/FALSE). Used for decision making and filtering.