vctrs (version 0.1.0)

vec_slice: Get or set observations in a vector

Description

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().

Usage

vec_slice(x, i)

vec_slice(x, i) <- value

Arguments

x

A vector

i

An integer or character vector specifying the positions or names of the observations to get/set.

value

Replacement values.

Examples

Run this code
# 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 DataCamp Workspace