Learn R Programming

rje (version 1.4)

last: Last element of a vector or list

Description

Returns the last element of a list or vector.

Usage

last(x)

Arguments

x
a list or vector.

Value

  • An object of the same type as x of length 1 (or empty if x is empty).

Details

Designed to be faster than using tail() or rev(), and cleaner than writing x[length(x)].

See Also

tail, rev.

Examples

Run this code
last(1:10)

Run the code above in your browser using DataLab