Get or set the length of vectors (including lists) and factors, and of any other R object for which a method has been defined.
length(x)
length(x) <- value
| Parameter | Description |
|---|---|
x |
an R object. For replacement, a vector or factor. |
value |
a non-negative integer or double (which will be rounded down). |
# NOT RUN {
length(diag(4)) # = 16 (4 x 4)
length(options()) # 12 or more
length(y ~ x1 + x2 + x3) # 3
length(expression(x, {y <- x^2; y+2}, x^y)) # 3
## from example(warpbreaks)
require(stats)
fm1 <- lm(breaks ~ wool * tension, data = warpbreaks)
length(fm1$call) # 3, lm() and two arguments.
length(formula(fm1)) # 3, ~ lhs rhs
# }