Skip to contents

Extracts a subset from an array. You can also use the [ operator. Supports R-style indexing including scalar indices (which drop dimensions), ranges (a:b), and array(c(...)) for selecting multiple elements along a dimension.

Usage

# S3 method for class 'AnvlBox'
x[...]

# S3 method for class 'AnvlArray'
x[...]

nv_subset(x, ...)

Arguments

x

(arrayish)
Array to subset.

...

Subset specifications, one per dimension. Omitted trailing dimensions select all elements. See vignette("subsetting") for details.

Value

arrayish

See also

nv_subset_assign() for updating subsets, vignette("subsetting") for a comprehensive guide.

Examples

x <- nv_array(matrix(1:12, nrow = 3))
# Select row 2
x[2, ]
#> AnvlArray
#>   2
#>   5
#>   8
#>  11
#> [ CPUi32{4} ] 

x <- nv_array(matrix(1:12, nrow = 3))
# Select rows 1 to 2, all columns
x[1:2, ]
#> AnvlArray
#>   1  4  7 10
#>   2  5  8 11
#> [ CPUi32{2,4} ]