Learn R Programming

BoardGames (version 1.0.0)

get_diags: Get all diagonals vectors of a matrix.

Description

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

Usage

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

Run this code
M = matrix(rnorm(9),3,3)
get_diags(M)

Run the code above in your browser using DataLab