DescTools (version 0.99.11)

Rev: Reverse Elements of a Vector or the Rows/Columns of Matrices and Tables

Description

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.

Usage

Rev(x, ...)

## S3 method for class 'matrix':
Rev(x, margin, \dots) 

## S3 method for class 'table':
Rev(x, margin, \dots)

Arguments

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.

See Also

rev, order, sort, seq

Examples

Run this code
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))

Run the code above in your browser using DataCamp Workspace