slice.index(x, MARGIN)
x <- array(data = 101:124, dim = c(4,3,2)) slice.index(x, 1)# Produces the following output: , , 1 [,1] [,2] [,3] [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [4,] 4 4 4
, , 2 [,1] [,2] [,3] [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [4,] 4 4 4
slice.index(x,3)
# Produces the following output: , , 1 [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 [3,] 1 1 1 [4,] 1 1 1
, , 2 [,1] [,2] [,3] [1,] 2 2 2 [2,] 2 2 2 [3,] 2 2 2 [4,] 2 2 2
split(x, group = slice.index(x,2)) # compare to x[,1,], x[,2,], x[,3,]
# Produces the following output: $"1": [1] 101 102 103 104 113 114 115 116
$"2": [1] 105 106 107 108 117 118 119 120
$"3": [1] 109 110 111 112 121 122 123 124