get_n_elements: Get N elements

View source: R/get_n_elements.R

get_n_elementsR Documentation

Get N elements

Description

Get only the first N elements from a named list.

Usage

get_n_elements(l, n = 1, simplify = TRUE, verbose = TRUE)

Arguments

l

A list.

n

The maximum number of elements to return from that list.

simplify

When the final length of the list is 1, unlist the object.

verbose

Print messages.

Value

A shortened list or a single element.

Examples

l <- lapply(seq(4),prod,3)
l1 <- get_n_elements(l, n=1)
l2 <- get_n_elements(l, n=2, simplify = FALSE)

bschilder/scKirby documentation built on April 22, 2024, 12:13 a.m.