mydiag: Matrix diagonal

mydiagR Documentation

Matrix diagonal

Description

Extract or replace the diagonal of a matrix, or construct a diagonal matrix (replace diag function from R-base)

Usage

mydiag(x = 1, nrow, ncol)

Arguments

x

a matrix, vector or 1D array, or missing.

nrow

Optional number of rows for the result when x is not a matrix.

ncol

Optional number of columns for the result when x is not a matrix.

Value

If x is a matrix then diag(x) returns the diagonal of x. The resulting vector will have names if the matrix x has matching column and rownames.

Author(s)

Emmanuelle Comets emmanuelle.comets@inserm.fr, Audrey Lavenu, Marc Lavielle.

See Also

diag

Examples


mydiag(1)
mydiag(c(1,2))


saemix documentation built on May 29, 2024, 10:43 a.m.

Related to mydiag in saemix...