head.list: Return the first or last part of a list

View source: R/functions.r

head.listR Documentation

Return the first or last part of a list

Description

Returns the first or last part of a list. Instead of returning the first n entries as the standard head() does, it attempts to call head() recursively on the entries in the list. If it fails, it will return the particular entry (standard behavior).

Usage

head.list(obj, n = 6L, ...)

Arguments

obj

a list object

n

a single integer. If positive, prints the first n items for the list and all entries in the list. If negative, prints all but the last n items in the list.

...

additional parameters passed on to head()

Value

a list of length n, with items in the list of length n

Author(s)

pimentel

References

https://gist.github.com/pimentel/256fc8c9b5191da63819

Examples

    a <- list()
    a[[1]] <- c(1:100)
    a[[2]] <- c(500:1000)
    head.list(a)
    # same result
    head(a)

freysimon/TigR documentation built on Jan. 26, 2024, 9:01 a.m.