Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nth

Extract the nth value from a vector


Description

Get the value from a vector with its position.

Usage

nth(v, n = 1)

Arguments

v

A vector

n

A single integer specifying the position. Default uses 1. Negative integers index from the end (i.e. -1L will return the last value in the vector). If a double is supplied, it will be silently truncated.

Value

A single value.

Examples

x = 1:10
nth(x, 1)
nth(x, 5)
nth(x, -2)

tidyft

Tidy Verbs for Fast Data Operations by Reference

v0.4.5
MIT + file LICENSE
Authors
Tian-Yuan Huang [aut, cre] (<https://orcid.org/0000-0002-3591-4203>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.