R: Reverse Elements (original) (raw)
rev {base} | R Documentation |
---|
Description
rev
provides a reversed version of its argument. It is generic function with a default method for vectors and one for[dendrogram](../../stats/html/dendrogram.html)
s.
Note that this is no longer needed (nor efficient) for obtaining vectors sorted into descending order, since that is now rather more directly achievable by [sort](../../base/help/sort.html)(x, decreasing = TRUE)
.
Usage
rev(x)
Arguments
x | a vector or another object for which reversal is defined. |
---|
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language. Wadsworth & Brooks/Cole.
See Also
[seq](../../base/help/seq.html)
, [sort](../../base/help/sort.html)
.
Examples
x <- c(1:5, 5:3)
## sort into descending order; first more efficiently:
stopifnot(sort(x, decreasing = TRUE) == rev(sort(x)))
stopifnot(rev(1:7) == 7:1) #- don't need 'rev' here
[Package _base_ version 4.6.0 Index]