Learn R Programming

Matrix (version 0.99-6)

Diagonal: Create Diagonal Matrix Object

Description

Create a diagonal matrix object, i.e., an object inheriting from diagonalMatrix-class.

Usage

Diagonal(n, x = NULL)

Arguments

n
integer specifying the dimension of the (square) matrix. If missing, length(x) is used.
x
numeric or logical; if missing, a unit diagonal $n \times n$ matrix is created.

Value

See Also

the generic function diag for extraction of the diagonal from a matrix; Matrix, diagonalMatrix-class

Examples

Run this code
Diagonal(3)
Diagonal(x = 10^(3:1))
Diagonal(x = (1:4) >= 2)#-> "ldiMatrix"

Run the code above in your browser using DataLab