Last chance! 50% off unlimited learning
Sale ends in
This provides a common interface to extracting and modifying observations
for all vector types, regardless of dimensionality. It is an analog to [
that matches vec_size()
instead of length()
.
vec_slice(x, i)vec_slice(x, i) <- value
A vector
An integer or character vector specifying the positions or names of the observations to get/set.
Replacement values.
# NOT RUN {
x <- sample(10)
x
vec_slice(x, 1:3)
vec_slice(x, 2L) <- 100
x
vec_slice(mtcars, 1:3)
# }
Run the code above in your browser using DataLab