Learn R Programming

datautils (version 0.1.5)

upper:

Description

Returns the (d*(d-1)/2) x 2 matrix of the (i,j) indexes to the upper triangle of a d x d matrix. The result can then directly be used as an index, see example.

Usage

upper(d)

Arguments

d
dimension of the square matrix which we intend to index.

Value

Index values

Examples

Run this code
inds <- upper(5)
vals <- matrix(runif(25), nrow=5)
selvals <- vals[inds] # vector containing the values of the upper triangle

Run the code above in your browser using DataLab