Learn R Programming

lava (version 1.5)

tr: Trace operator

Description

Calculates the trace of a square matrix.

Usage

tr(x, ...)

Arguments

x
Square numeric matrix
Additional arguments to lower level functions

Value

numeric

See Also

crossprod, tcrossprod

Examples

Run this code

tr(diag(1:5))

Run the code above in your browser using DataLab