Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

acorn

Return a corner of an array object (like head)


Description

Return a small corner of an array object, like head() or tail() but taking only a few slices on each dimension.

Usage

acorn(x, n=6, m=5, r=1, ...)

Arguments

x

An array (including a matrix or a data frame)

n,m,r

Numbers of items on each dimension. A negative number is interpreted as this many items at the end (like tail).

...

Further arguments specifying numbers of slices to return on each dimension.

Details

Like head() for multidimensional arrays, with two differences: (1) returns just a few items on each dimension, and (2) negative numbers are treated like tail().

Value

An object like x with fewer elements on each dimension.

Author(s)

Tony Plate tplate@acm.org

Examples

x <- array(1:24,dim=c(4,3,2),dimnames=rev(list(letters[1:2],LETTERS[1:3],letters[23:26])))
acorn(x)
acorn(x, 3)
acorn(x, -3)
acorn(x, 3, -2)

abind

Combine Multidimensional Arrays

v1.4-5
LGPL (>= 2)
Authors
Tony Plate <tplate@acm.org> and Richard Heiberger
Initial release
2016-06-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.