Diag {lazy.mat}R Documentation

Diag(x) creats a diagonam matrix from its argument vector or matrix

Description

Diag(x) creats a diagonam matrix from its argument vector or matrix

Usage

Diag(x, drop = FALSE)

Arguments

x

Input square matrix or scalar

drop

= 1 to make the result a scalar when Diag(x) is 1 x 1.

Details

Diag(x) returns a diagonal matrix whose diagonal elements are:
1) the diagonal elements of x when x is a genuine matrix,
2) x when x is a vector, row vector, or column vector.

Can be used with a character matrix

Value

A diagonal matrix

Examples

Diag(demomat(2,2))
Diag(1:3)
Diag(matrix(1:3,1))
Diag(2)

[Package lazy.mat version 0.1.3 Index]