# NOT RUN {
x <- rray(10:17, c(2, 2, 2))
# Resulting dimension is always 1D, and is a base R array
rray_yank(x, 1:3)
# Subsetting with a logical is possible if it is either
# length 1 or the length of `x`
rray_yank(x, FALSE)
rray_yank(x, rep(c(TRUE, FALSE), times = rray_elems(x) / 2))
# You can assign a 1D vector to these yanked selections
# Length 1 values are recycled as required
rray_yank(x, c(1, 3, 5)) <- 9
# `rray_yank()` powers `[[` as well
# Notably, you can yank multiple values in `[[`
x[[c(1, 3, 5)]] <- NA
# Logicals with the same dim as `x` can also be used as a yank indexer
# This comes in handy as a way to remove NA values
x[[is.na(x)]] <- 0
# }
Run the code above in your browser using DataLab