dist_replace {disto}R Documentation

Replacement values in dist

Description

Replacement values of a dist object with either ij or position indexing

Usage

dist_replace(object, i, j, value, k)

Arguments

object

dist object

i

(integer vector) row positions

j

(integer vector) column positions

value

(integer/numeric vector) Values to replace

k

(integer vector) positions

Details

There are two modes to specify the positions:

Value

dist object

Examples


# create a dist object
d <- dist(iris[,1:4])
attr(d, "Labels") <- outer(letters, letters, paste0)[1:150]
head(d)
max(d)
as.matrix(d)[1:5, 1:5]

# replacement in ij-mode
d <- dist_replace(d, 1, 2, 100)
dist_extract(d, 1, 2, product = "inner")
d <- dist_replace(d, "ca", "ba", 102)
dist_extract(d, "ca", "ba", product = "inner")

d <- dist_replace(d, 1:5, 6:10, 11:15)
dist_extract(d, 1:5, 6:10, product = "inner")
d <- dist_replace(d, c("ca", "da"), c("aa", "ba"), 102)
dist_extract(d, c("ca", "da"), c("aa", "ba"), product = "inner")

# replacement in k-mode
d <- dist_replace(d, k = 2, value = 101)
dist_extract(d, k = 2)
dist_extract(d, 3, 1, product = "inner") # extracting k=2 in ij-mode

[Package disto version 0.2.0 Index]