Replace parts of bigdist

bigdist_replace(x, i, j, value, k)

Arguments

x

Object of class 'bigdist'

i

(integer vector) row positions

j

(integer vector) column positions

value

(integer/numeric vector) Values to replace

k

(integer vector) positions

Value

bigdist object

Details

There are two modes to specify the positions:

  • ij-mode where i and j are specified and k is missing. If i or j are missing, they are interpreted as all values of i or j (similar to matrix or dataframe subsetting). Lengths of i, j are required to be same. If 'value' is singleton, then it is extended to the length of i or j. Else, 'value' should have same length as i or j.

  • k-mode where k is present and both i and k are missing. k is the positions in the dist object. If 'value' is singleton, then it is extended to the length of k. Else, 'value' should have same length as k.

Examples

set.seed(1) amat <- matrix(rnorm(1e3), ncol = 10) td <- tempdir() temp <- bigdist(mat = amat, file = file.path(td, "temp_ex7"))
#> ----
#> Location: /tmp/RtmpNBdlQr/temp_ex7_100_float.bk
#> Size on disk: 0 GB
#> Computing distances ...
#> Completed!
#> ----
bigdist_replace(temp, 1, 2, 10)
#> $fbm #> A Filebacked Big Matrix of type 'float' with 100 rows and 100 columns. #> #> attr(,"class") #> [1] "bigdist"
bigdist_extract(temp, 1, 2)
#> [,1] #> [1,] 10
bigdist_replace(temp, 1:2, 3:4, 11:12)
#> $fbm #> A Filebacked Big Matrix of type 'float' with 100 rows and 100 columns. #> #> attr(,"class") #> [1] "bigdist"
bigdist_extract(temp, 1:2, 3:4, product = "inner")
#> [1] 11 12