[ top | up ]

Row Indexes

Syntax

row(x)

Description

row takes a matrix as argument and returns an integer matrix with the same dimensions. The ij-th element of row(c) is equal to i.

Examples

# extract the diagonal of a matrix dx <- x[row(x)==col(x)] # create an identity 5-by-5 matrix x <- matrix(0,nr=5,nc=5) x[row(x)==col(x)] <- 1