addDist {rrp}R Documentation

Adds constant to the elements of a dist object vector-wise

Description

Adds constant to the elements of a dist object vector-wise. The idea is that a symmetrix matrix M can be represented as a triangular object {d}. With this function you set M[x,x] = M[x,x] + k but instead of working on M this function works on its dist representation d.

Usage

addDist(d, x, k)

Arguments

d a dist object, upper diagonal, representing a symmetric matrix
x a vector of indices
k the constant to add

Value

returns the modified dist object

Author(s)

Stefano M. Iacus

See Also

dist

Examples

M <- matrix(1:100,5,20)
M <- M 
d <- as.dist(M)
x <- 1:3

addDist(d,x,-80000)
d
# which is the equivalent of (apart for the diagonal elements)
M[x,x] <- M[x,x] - 80000

# Indeed, we have
d
as.dist(M)

[Package rrp version 1.4 Index]