I am working on some data in R that consist of four-dimensional arrays composed of three spatial dimensions and a time dimension: x, y, z, t. For some of my analyses, I woul
I think you are looking for:
apply(a4d, 4, `[`, indices)
And to check that our results match:
result1 <- matrix(result[,5], ncol = 10) result2 <- apply(a4d, 4, `[`, indices) identical(result1, result2) # [1] TRUE