Diag: Diagonal Matrix

View source: R/linpk.R

DiagR Documentation

Diagonal Matrix

Description

Like the base diag function, except that vectors of length one are converted to 1-by-1 matrices, values can be specified either as a single vector argument or multiple arguments, and row and column names can be specified.

Usage

Diag(x, ..., .names = names(x), .colnames = .names, .rownames = .names)

Arguments

x

A numeric (or number-like) vector (possibly named).

...

Additional numeric (or number-like) vectors (possibly named).

.names, .colnames, .rownames

Optionally, specify the row and column names of the resulting diagonal matrix.

Examples

Diag(6)
Diag(3.14, .names="pi")
Diag(1:6, .colnames=LETTERS[1:6], .rownames=letters[1:6])
Diag(1, 2, 3)
Diag(a=1, b=2, c=3)
Diag(a=1, c(b=2, c=3))
Diag(2+3i, 4+5i)

benjaminrich/linpk documentation built on April 18, 2024, 2:13 a.m.