extract_element_at: Subsetting element from a list-like type object.

extract_element_atR Documentation

Subsetting element from a list-like type object.

Description

Extracting the element from each slot of a list. It behaves like lapply, e.g. lapply(x, tail, n = 1 is similar to last_element(x), but the latter one will be much faster. For the speed, extract_element_at(x, 1) is slightly slower than first_element.

Usage

first_element(x, invert = FALSE)
last_element(x, invert = FALSE)
extract_element_at(x, invert = FALSE)

Arguments

x

A list like object.

invert

A logical scalar specifying whether extract element except the selected one, x.

Details

It also works with GRangesList and List.

Value

A list containing the selected element from the each slot in the list.

Author(s)

Cheuk-Ting Law

Examples

x <- list(c(1:10), c(5:20))
first_element(x)
first_element(x, invert = TRUE)
last_element(x)
extract_element_at(x, 3)

ctl43/TranSpotteR documentation built on Sept. 9, 2022, 5:49 p.m.