Concept Flow - Integer type
Start
Assign integer value
Check type with typeof()
Use integer in calculations
Output result
End
This flow shows how an integer value is assigned, checked for type, used in calculations, and then output.
x <- 5L print(typeof(x)) result <- x + 3L print(result)
| Step | Action | Variable | Value | Type | Output |
|---|---|---|---|---|---|
| 1 | Assign integer 5L to x | x | 5 | integer | |
| 2 | Check type of x | x | 5 | integer | integer |
| 3 | Add 3L to x and assign to result | result | 8 | integer | |
| 4 | Print result | result | 8 | integer | 8 |
| Variable | Start | After Step 1 | After Step 3 | Final |
|---|---|---|---|---|
| x | undefined | 5 | 5 | 5 |
| result | undefined | undefined | 8 | 8 |
Integer type in R: - Use L suffix (e.g., 5L) to create integer literals. - typeof() shows variable type. - Integer + Integer = Integer. - Default numbers without L are double type. - Integers save memory and are exact whole numbers.