Concept Flow - Numeric type
Start
Assign numeric value
Store as numeric type
Use in calculations
Output result
End
This flow shows how a numeric value is assigned, stored as a numeric type, used in calculations, and then output.
x <- 5.5 print(x) y <- x * 2 print(y)
| Step | Action | Variable | Value | Output |
|---|---|---|---|---|
| 1 | Assign 5.5 to x | x | 5.5 | |
| 2 | Print x | x | 5.5 | 5.5 |
| 3 | Calculate y = x * 2 | y | 11.0 | |
| 4 | Print y | y | 11.0 | 11 |
| 5 | End of code |
| Variable | Start | After Step 1 | After Step 3 | Final |
|---|---|---|---|---|
| x | undefined | 5.5 | 5.5 | 5.5 |
| y | undefined | undefined | 11.0 | 11.0 |
Numeric type in R stores numbers with or without decimals. Assign with <-, e.g., x <- 5.5. Used in calculations like y <- x * 2. Print values with print(). Decimals mean numeric (double) type.