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

Description Usage Arguments Author(s) See Also Examples

View source: R/DescTools.r

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

1
2
3
4
5
6
7
Rev(x, ...)

## S3 method for class 'matrix'
Rev(x, margin, ...) 

## S3 method for class 'table'
Rev(x, margin, ...) 

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.

Author(s)

Andri Signorell <andri@signorell.net>

See Also

rev, order, sort, seq

Examples

1
2
3
4
5
6
7
8
9
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))                  

DescTools documentation built on Sept. 13, 2017, 9:04 a.m.