Concept Flow - Vector creation with c()
Start
Call c() with elements
Combine elements into vector
Return vector
Use vector in code
The c() function takes elements and combines them into a single vector, which can then be used in your R code.
v <- c(1, 2, 3, 4) print(v)
| Step | Action | Input Elements | Resulting Vector | Output |
|---|---|---|---|---|
| 1 | Call c() with elements | 1, 2, 3, 4 | c(1, 2, 3, 4) | |
| 2 | Assign vector to v | c(1, 2, 3, 4) | v <- c(1, 2, 3, 4) | |
| 3 | Print vector v | v = c(1, 2, 3, 4) | c(1, 2, 3, 4) | [1] 1 2 3 4 |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| v | NULL | NULL | c(1, 2, 3, 4) | c(1, 2, 3, 4) |
c() combines multiple elements into a vector. Syntax: c(element1, element2, ...) All elements become the same type. Use c() to create simple vectors quickly. Vectors are basic data structures in R.