SparseArray-subassignment | R Documentation |
Like ordinary arrays in base R, SparseArray derivatives support
subassignment via the [<-
operator.
[<-
in base R.
SparseArray objects.
Ordinary array objects in base R.
a <- array(0L, dim=5:3)
a[c(1:2, 8, 10, 15:17, 20, 24, 40, 56:60)] <- (1:15)*10L
svt <- SparseArray(a)
svt
svt[5:3, c(4,2,4), 2:3] <- -99L
## Sanity checks:
a[5:3, c(4,2,4), 2:3] <- -99L
stopifnot(identical(as.array(svt), a), identical(svt, SparseArray(a)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.