get_diags: Get all diagonals vectors of a matrix.

Description Usage Arguments Examples

View source: R/get_surround.R

Description

This function extracts all diagonal vectors of a matrix and returns the result as a list.

Usage

1
get_diags(data, direction = "right")

Arguments

data

Matrix from which to extract diagonal elements

direction

Which side to begin on? Takes values of one of "left", "right" or "both". Defaults to "right".

Examples

1
2
M = matrix(rnorm(9),3,3)
get_diags(M)

Example output

$`-2`
[1] -0.7398676

$`-1`
[1]  1.3014470 -0.8211806

$`0`
[1] -0.1364061 -1.1788488  0.1427320

$`1`
[1] -0.5590616 -0.0878490

$`2`
[1] -0.1569791

BoardGames documentation built on May 2, 2019, 3:45 a.m.