1 2
for (m in marg) ## 75% of the time here was spent on the names print(dim(apply(arr, print(m), quantile, names = FALSE)) == c(5, d.arr[m]))