mirror {omnibus} | R Documentation |
Flip an object
Description
This function creates a "mirror" image of a character string, a number, a matrix, or a data frame. For example "Shots were exchanged at the hospital" becomes "latipsoh eht ta degnahcxe erew stohS' and 3.14159 becomes 95141.3. Data frames and matrices will be returned with the order of columns or order of rows reversed.
Usage
mirror(x, direction = "lr")
Arguments
x |
A vector of numeric or character values, or a matrix or data frame. |
direction |
Only used if |
Value
Object with same class as x
.
Examples
x <- 'Shots were exchanged at the hospital'
mirror(x)
x <- c('Water', 'water', 'everywhere')
mirror(x)
# last value will return NA because the exponentiation does not
# make sense when written backwards
x <- c(3.14159, 2.71828, 6.02214076e+23)
mirror(x)
x <- data.frame(x=1:5, y=6:10)
mirror(x)
x <- matrix(1:10, nrow=2)
mirror(x)
[Package omnibus version 1.2.13 Index]