DescTools (version 0.99.8.1)

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 data.frames, matrices and tables, such as to reverse the order of rows and columns.

Usage

Rev(x, ...)

## S3 method for class 'matrix':
Rev(x, direction = c("row", "column", "both"), ...) 

## S3 method for class 'table':
Rev(x, direction = c("row", "column", "both"), ...) 

## S3 method for class 'data.frame':
Rev(x, direction = c("row", "column", "both"), ...)

Arguments

x
a data.frame, a matrix or a table to be reversed.
direction
defines the dimensions in which the elements are to be reversed. This can be any value out of c("row", "column", "both"), default being "row". If it is set to "both" then rows and colu
...
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, direction="row")                  
Rev(tab, direction="column")                  

# abbreviations are accepted
Rev(tab, direction="b")

Run the code above in your browser using DataCamp Workspace