extract_last: Subset object using Python's negative indexing

View source: R/subsetting.R

extract_lastR Documentation

Subset object using Python's negative indexing

Description

Subset object using Python's negative indexing, that is, by counting indices backwards.

Usage

extract_last(x, margin_1 = NULL, margin_2 = NULL, drop = FALSE)

Arguments

x

(vector, data.frame or matrix) Object to subset.

margin_1

(integer vector) Indices for the first (vertical) margin.

margin_2

(integer vector) Indices for the second (horizontal) margin.

drop

(logical scalar) Whether to convert to a vector if there is only 1 column. Default=FALSE.

Value

Returns the subset of the object.

Examples

extract_last(iris, 1) # last row
extract_last(iris, , 1) # last column
extract_last(iris, 5:1, 2:1) #last 5 elements rows and last 2 columns

Deleetdk/kirkegaard documentation built on May 2, 2024, 7:12 p.m.