Description Usage Arguments Value See Also Examples
Converts different index types such as negative integer vectors, character vectors, or logical vectors into positive integer vectors.
1 | convertIndex(x, i, type, allowDoubles = FALSE)
|
x |
A matrix-like object. |
i |
The index to convert: may be a one-dimensional or two-dimensional logical, character, integer, or double vector. |
type |
The type of index to convert to: |
allowDoubles |
If set, indices of type double are not converted to integers if the
operation would overflow to support matrices with |
The converted index.
extract
and replace
to generate implementations
for [
and [<-
for custom types that use convertIndex
under the hood.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | x <- matrix(data = rnorm(25), nrow = 5, ncol = 5)
dimnames(x) <- list(letters[1:5], letters[1:5])
convertIndex(x, c(1, 2, 3), "k")
convertIndex(x, -25, "k")
convertIndex(x, c(TRUE, FALSE), "k")
convertIndex(x, c(1, 2, 3), "i")
convertIndex(x, -5, "i")
convertIndex(x, c(TRUE, FALSE), "i")
convertIndex(x, c("a", "b", "c"), "i")
convertIndex(x, c(1, 2, 3), "j")
convertIndex(x, -5, "j")
convertIndex(x, c(TRUE, FALSE), "j")
convertIndex(x, c("a", "b", "c"), "j")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.