| Rev {DescTools} | R Documentation |
Rev provides a reversed version of its argument.
It wraps the base function rev and provides an additional method for matrices and higher dimensional tables, such as to reverse the order of rows and columns.
Rev(x, ...) ## S3 method for class 'matrix' Rev(x, margin, ...) ## S3 method for class 'table' Rev(x, margin, ...) ## S3 method for class 'data.frame' Rev(x, margin, ...)
x |
a vector, a matrix or a higher dimensional table to be reversed. |
margin |
vector of dimensions which to be reversed (1 for rows, 2 for columns, etc.). |
... |
the dots are passed to the matrix, resp. table interface. |
Andri Signorell <andri@signorell.net>
tab <- matrix( c( 1, 11, 111,
2, 22, 222,
3, 33, 333), byrow=TRUE, nrow=3)
Rev(tab, margin=1)
Rev(tab, margin=2)
# reverse both dimensions
Rev(tab, margin=c(1,2))