getlast {FastUtils}R Documentation

Get the Last Elements of a Vector or List

Description

This function retrieves the last n elements of a vector or list.

Usage

getlast(x, n = 1)

## Default S3 method:
getlast(x, n = 1)

Arguments

x

A vector, list, or other supported data type.

n

An integer specifying the number of elements to retrieve from the end. Default is 1.

Value

The last n elements of the input.

Examples

# Get the last element of a vector
getlast(c(1, 2, 3, 4, 5))
# Get the last 2 elements of a vector
getlast(c(1, 2, 3, 4, 5), 2)
# Get the last element of a list
getlast(list("a", "b", "c"))
# Get the last 2 elements of a list
getlast(list("a", "b", "c"), 2)

[Package FastUtils version 0.1.1 Index]