Picks one or more elements along dimension dim of operand.
Use this instead of [ or nv_subset when the index to select is provided
programmatically.
Usage
nv_select(operand, dim, index)
Arguments
- operand
(arrayish)
Operand.
- dim
(integer(1))
Dimension to index into.
- index
(arrayish)
Scalar or 1D arrayish input (integer).
Value
arrayish
Same data type as operand. dim is dropped if index was scalar.
Examples
m <- nv_matrix(1:6, nrow = 2)
nv_select(m, dim = 2L, index = 2L)
#> AnvlArray
#> 3
#> 4
#> [ CPUi32{2} ]
nv_select(m, dim = 1L, index = 1L)
#> AnvlArray
#> 1
#> 3
#> 5
#> [ CPUi32{3} ]
nv_select(m, dim = 2L, index = array(c(1L, 3L)))
#> AnvlArray
#> 1 5
#> 2 6
#> [ CPUi32{2,2} ]