vecs: Vector of matrix elements above diagonal

Description Usage Arguments Value Author(s) Examples

View source: R/vecs.R

Description

Stacks the rows of the upper diagonal of a symmetric matrix in a vector.

Usage

1
vecs(datamat)

Arguments

datamat

A symmetric matrix.

Value

Returns a vector containing the elements in the stacked rows of the upper diagonal of datamat.

Author(s)

Theo Pepler

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (datamat)
{
    p <- ncol(datamat)
    outputvec <- NULL
    for (j in 1:p) {
        outputvec <- append(outputvec, datamat[j, j:p])
    }
    return(outputvec)
  }

tpepler/theolib documentation built on Aug. 10, 2021, 9:53 a.m.