Description Usage Arguments Details Value Examples
Matrix style extraction supports 'inner' and 'outer'(default) products
1 | dist_extract(object, i, j, k, product = "outer")
|
object |
dist object |
i |
(integer vector) row positions |
j |
(integer vector) column positions |
k |
(integer vector) positions |
product |
(string) One among: 'inner', 'outer'(default) |
In k-mode, both i and j should be missing and k should not be missing. In ij-mode, k should be missing and both i and j are optional. If i or j are missing, they are interpreted as all values of i or j (similar to matrix or dataframe subsetting). If i and j are of unequal length, the smaller one is recycled.
A matrix or vector of distances when product is 'outer' and 'inner' respectively
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # examples for dist_extract
# create a dist object
temp <- dist(iris[,1:4])
attr(temp, "Labels") <- outer(letters, letters, paste0)[1:150]
head(temp)
max(temp)
as.matrix(temp)[1:5, 1:5]
dist_extract(temp, 1, 1)
dist_extract(temp, 1, 2)
dist_extract(temp, 2, 1)
dist_extract(temp, "aa", "ba")
dist_extract(temp, 1:10, 11:20)
dim(dist_extract(temp, 1:10, ))
dim(dist_extract(temp, , 1:10))
dist_extract(temp, 1:10, 11:20, product = "inner")
length(dist_extract(temp, 1:10, , product = "inner"))
length(dist_extract(temp, , 1:10, product = "inner"))
dist_extract(temp, c("aa", "ba", "ca"), c("ca", "da", "fa"))
dist_extract(temp, c("aa", "ba", "ca"), c("ca", "da", "fa"), product = "inner")
dist_extract(temp, k = 1:3) # product is always inner when k is specified
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.