x <- rvar(array(1:24, dim = c(4,2,3)))
dimnames(x) <- list(c("a","b"), c("d","e","f"))
x
## Slicing single elements
# x[[]]
x[[2]]
# x[[]]
# notice the draws of x[1:4]...
draws_of(x[1:4])
x[[rvar(c(1,3,4,4))]]
# ... x[[rvar(c(1,3,4,4))]] creates a mixures of those draws
draws_of(x[[rvar(c(1,3,4,4))]])
# x[[i_1,i_2,...]]
x[[2,"e"]]
## Slicing multiple elements
# x[]
x[c(TRUE,TRUE,FALSE)]
# x[]
# select every other draw
x[rvar(c(TRUE,FALSE,TRUE,FALSE))]
# x[]
x[1:3]
# x[]
x[rbind(
c(1,2),
c(1,3),
c(2,2)
)]
# x[i_1,i_2,...,i_n]
x[1,]
x[1,2:3]
x[,2:3]
Run the code above in your browser using DataLab