tab <- matrix(c(1, 11, 111,
2, 22, 222,
3, 33, 333),
byrow=TRUE, nrow=3,
dimnames=list(mar1=1:3, mar2=c("a","b","c")))
Rev(tab, margin=1)
Rev(tab, margin=2)
# reverse both dimensions
Rev(tab, margin=c(1, 2))
t(tab)
# reverse 3dimensional array
aa <- Abind(tab, 2 * tab, along=3)
dimnames(aa)[[3]] <- c("A","Z")
# reverse rows
Rev(aa, 1)
# reverse columns
Rev(aa, 2)
# reverse 3th dimension
Rev(aa, 3)
# reverse all dimensions
Rev(aa)
# same as
Rev(aa, margin=(1:3))
Run the code above in your browser using DataLab