powered by
Extract the first, last, or nth value from a vector.
Note: These are simple wrappers around vctrs::vec_slice().
vctrs::vec_slice()
first.(x, default = NA)last.(x, default = NA)nth.(x, n, default = NA)
last.(x, default = NA)
nth.(x, n, default = NA)
A vector
The default value if the value doesn't exist.
For nth.(), a number specifying the position to grab.
nth.()
# NOT RUN { vec <- letters first.(vec) last.(vec) nth.(vec, 4) # }
Run the code above in your browser using DataLab