c() (vector)
Try it yourself →Collection of ordered values.
Syntax
v <- c(a, b, c); v[1]; length(v)
Description
Vectors are created with c(). CAUTION: R is 1-indexed — the first element is v[1]. length() gives the number of elements. To append, use v <- c(v, yeni).
Example
v <- c(1, 2) v <- c(v, 3) cat(v[1], "\n", sep="") cat(length(v), "\n", sep="")
Expected output
1 3
When to use?
Data series, measurements, categories.
Common mistakes
- ⚠️ The first element is v[1], not v[0] (1-indexed).