Learn R Programming

BaTFLED3D (version 0.2.11)

diagonal: Version of diag that has more consistent behavior

Description

Version of diag that has more consistent behavior

Usage

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

Run this code
# NOT RUN {
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)))
# }

Run the code above in your browser using DataLab