Skip to contents

Double bracket '[[' refers to elements'/layers' name in the @stack of the 'VirtualArray'-derived object. Use single brackets to extract elements based on their position in the 'VirtualArray'.

Usage

# S4 method for VirtualArray,ANY,ANY
[[(x, i, drop = TRUE)

Arguments

x

VirtualArray

i

subscript of the first dimension(rows) or vector-like subsetting.

drop

logical should the VirtualArray be dropped and the element be reduced to the element class?

Value

A VirtualArray-derived class object, or an object of the class that makes up the VirtualArray

Examples

data(exemplar)
# finds a layer
exemplar[["sample1"]]
#>     x          y
#> 1   1 -43.659256
#> 14 14 -20.793723
#> 34 34 -25.883039
#> 39 39  -8.181445
#> 43 43 -19.785609
#> 51 51   7.698047
#> 59 59  -5.043689
#> 68 68  17.948349
#> 82 82  12.174447
#> 87 87  17.821889
# returns a stack
exemplar[[c("sample1", "sample2")]]
#> class         : XArray 
#> Element properties: 
#> - class       :  data.frame 
#> Array properties: 
#> - dimensions  : 2  (vector)
#> - num. layers : 2
#> - missing     : 0
#> - proxy:
#>  [1] "sample1" "sample2"
#> 
# replaces a layervalues, but not the attributes of the layer
exemplar2 <- exemplar
exemplar2[["sample1"]] <- exemplar2[["sample2"]]
# compare every value in the they are all the same
exemplar2[["sample1"]]$x == exemplar2[["sample2"]]$x
#>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [16] TRUE TRUE TRUE TRUE TRUE