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

arow

Generalized row and col


Description

Given an array, returns an array of the same size whose elements are sequentially numbered along the i-th dimension.

Usage

arow(a, i)

Arguments

a

array to be converted

i

Number of the dimension

Value

An integer matrix with the same dimensions as a, with element (n1,n2, ..., n_d) being n_i.

Note

This function is equivalent to, but faster than, function(a,i){do.index(a,function(x){x[i]})}. However, it is much more complicated.

The function is nominally the same as slice.index() but I have not checked all the edge cases.

Author(s)

Robin K. S. Hankin

Examples

a <- array(0,c(3,3,2,2))
arow(a,2)
(arow(a,1)+arow(a,2)+arow(a,3)+arow(a,4))%%2

magic

Create and Investigate Magic Squares

v1.5-9
GPL-2
Authors
Robin K. S. Hankin
Initial release
2018-09-14

We don't support your browser anymore

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