Extract parts of bigdist

bigdist_extract(x, i, j, k, product = "outer")

Arguments

x

Object of class 'bigdist'

i

(integer vector) row positions

j

(integer vector) column positions

k

(integer vector) positions

product

(string) One among: 'inner', 'outer'(default)

Value

A matrix or vector of distances when product is 'outer' and 'inner' respectively

Details

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).

Examples

set.seed(1) amat <- matrix(rnorm(1e3), ncol = 10) td <- tempdir() temp <- bigdist(mat = amat, file = file.path(td, "temp_ex6"))
#> ----
#> Location: /tmp/RtmpNBdlQr/temp_ex6_100_float.bk
#> Size on disk: 0 GB
#> Computing distances ...
#> Completed!
#> ----
bigdist_extract(temp, 1, 2)
#> [,1] #> [1,] 4.631341
bigdist_extract(temp, 1:2, 3:4)
#> [,1] [,2] #> [1,] 3.976406 3.531089 #> [2,] 5.591309 4.661480
bigdist_extract(temp, 1:2, 3:4, product = "inner")
#> [1] 3.976406 4.661480
dim(bigdist_extract(temp, 1:2,))
#> [1] 2 100
dim(bigdist_extract(temp, , 3:4))
#> [1] 100 2