nth_help: Extract elements by numeric position

View source: R/Nth.R

nth_helpR Documentation

Extract elements by numeric position

Description

Extract the n-th, n-th from last, first n, and last n elements of a vector of list.

Usage

nth_help()

.nth(x, n)

.first_n(x, n)

.last_n(x, n)

.nth_from_last(x, n)

.nth_plus(x, n)

Arguments

x

A populated vector to extract elements from.

n

A complete positive whole-number scalar.

Value

A scalar, vector, or vlist.

Functions

  • .nth(): Gets the n-th element(s) of x.

  • .first_n(): Gets the first n elements of x.

  • .last_n(): Gets the last n elements of x.

  • .nth_from_last(): Gets the nth from last element(s) of x.

  • .nth_plus(): Gets element n and onwards of x.

Examples

.nth_from_last(letters, 5)
.nth_plus(letters, 5)
.first_n(letters, 5)
.last_n(letters, 5)
.nth(letters, 5:7)

j-martineau/uj documentation built on Sept. 14, 2024, 4:40 a.m.