Learn R Programming

ipdmeta (version 1.1)

get.diag: Extract Diagonal Elements from Matrix

Description

Wrapper for diag that allows for scalar argument.

Usage

get.diag(x,...)

Arguments

x
Matrix or scalar
...
Additional arguments to diag

Value

  • Diagonal as vector.

Details

Same as diag but interprets scalar as scalar rather than the elements of an identity matrix. Thus if x is scalar or vector it is simply returned.

See Also

diag

Examples

Run this code
get.diag(matrix(1:4,2,2))

get.diag(4)

Run the code above in your browser using DataLab