rray_slice()
is a shortcut wrapper around rray_subset()
that is useful
for easily subsetting along a single axis.
rray_slice(x, i, axis) < value rray_slice_assign(x, i, axis, value) rray_slice(x, i, axis)
x  A vector, matrix, array or rray. 

i  Indices to extract along a single axis.

axis  An integer. The axis to subset along. 
value  A value to be assigned to the location at

x
with the i
elements extracted from the axis
.
rray_slice()
does exactly the same thing as rray_subset()
, and is
mainly helpful for higher dimensional objects, when you need to subset
along, for example, only the 4th dimension.
Other rray subsetters: rray_extract<
,
rray_subset<
, rray_yank<
#> <rray<int>[,1,2,2][2]> #> , , 1, 1 #> #> [,1] #> [1,] 1 #> [2,] 2 #> #> , , 2, 1 #> #> [,1] #> [1,] 5 #> [2,] 6 #> #> , , 1, 2 #> #> [,1] #> [1,] 9 #> [2,] 10 #> #> , , 2, 2 #> #> [,1] #> [1,] 13 #> [2,] 14 #># rray_slice() is particularly useful for # subsetting higher dimensions because you don't # have to worry about the commas rray_slice(x, i = 2, axis = 4)#> <rray<int>[,2,2,1][2]> #> , , 1, 1 #> #> [,1] [,2] #> [1,] 9 11 #> [2,] 10 12 #> #> , , 2, 1 #> #> [,1] [,2] #> [1,] 13 15 #> [2,] 14 16 #># Compare the above with the equivalent using `[` x[, , , 2]#> <rray<int>[,2,2,1][2]> #> , , 1, 1 #> #> [,1] [,2] #> [1,] 9 11 #> [2,] 10 12 #> #> , , 2, 1 #> #> [,1] [,2] #> [1,] 13 15 #> [2,] 14 16 #># `i` can be a character vector if `x` has names along `axis` x < rray_set_axis_names(x, axis = 4, c("foo", "bar")) rray_slice(x, "bar", axis = 4)#> <rray<int>[,2,2,1][2]> #> , , 1, bar #> #> [,1] [,2] #> [1,] 9 11 #> [2,] 10 12 #> #> , , 2, bar #> #> [,1] [,2] #> [1,] 13 15 #> [2,] 14 16 #>