Learn R Programming

compositions (version 2.0-4)

gsi.diagGenerate: Internal functions: Generate a diagonal matrix

Description

Generate a diagonal matrix from a vector of the diagonal entries like.

Usage

gsi.diagGenerate(x)

Value

a diagonal matrix.

Arguments

x

a vector

Author

K.Gerald v.d. Boogaart http://www.stat.boogaart.de

Details

The difference to original diag is that it always gives a diagonal matrix and does nothing flawed in case of a length one vector.

See Also

gsi.diagExtract, diag

Examples

Run this code
diag(1:3)
#gsi.diagGenerate(1:3)
#gsi.diagGenerate(3)
diag(3)

Run the code above in your browser using DataLab