get1dFrom2d {dissimilarities}R Documentation

2D-indexing to 1D-indexing

Description

Efficiently computes 1D-indexing from 2D-indexing

Usage

get1dFrom2d(i,j, N)

Arguments

i

An integer specifying the row index

j

An integer specifying the column index - must be different from i as "dist" object does not store the diagonal entries.

N

The number of observations in the original data matrix

Details

Converts 2D indexing (a row-column pair) into 1D indexing (as used in R's "dist" objects), given the number of observations N.

Currently, name-based indexing is not supported."

Value

An integer specifying the 1d index

Author(s)

Minh Long Nguyen edelweiss611428@gmail.com

Examples

N = 5
for(i in 1:4){
  for(j in (i+1):5){
    print(get1dFrom2d(i,j,N))
  }
}


[Package dissimilarities version 0.3.0 Index]