Learn R Programming

compositions (version 2.0-0)

gsi.diagExtract: Internal functions: Get the diagonal of a matrix

Description

Get the main diagonal of a matrix, even if the matrix is 1x1.

Usage

gsi.diagExtract(x)

Arguments

x

a matrix

Value

a vector containing the main diagonal entries of x.

Details

The difference to original diag is that it always gives the diagonal and does nothing flawed in case of a 1x1 matrix or a single number considered as such matrix.

See Also

gsi.diagGenerate, diag

Examples

Run this code
# NOT RUN {
#data(SimulatedAmounts)
#gsi.diagExtract(var(acomp(sa.lognormals,c(1,2))))
#gsi.diagExtract(var(ilr(acomp(sa.lognormals,c(1,2)))))
#gsi.diagExtract(var(ilt(aplus(sa.lognormals,c(1)))))
# }

Run the code above in your browser using DataLab