diagonal: Version of diag that has more consistent behavior

Description Usage Arguments Value Examples

View source: R/diagonal.R

Description

Version of diag that has more consistent behavior

Usage

1
diagonal(x, len = NA, ...)

Arguments

x

A vector, matrix or array with third mode length 1

len

numeric dimensions of new diagonal matrix to me made. Recycles values in x.

...

parameters passed to diag

Value

if x is a vector or integer, return a matrix with x on the diagonal. If x is a matrix, or degenerate array, return the diagonal of x.

Examples

1
2
3
4
5
diagonal(c(1,3))
diagonal(matrix(1:6, 2,3))
diagonal(5)
diagonal(c(5,2),3)
diagonal(array(1:12, dim=c(3,4,1)))

nathanlazar/BaTFLED3D documentation built on May 23, 2019, 12:19 p.m.