flip | R Documentation |
Flip an array along some dimension(s), e.g. flip a matrix upside down or left to right.
flip(x, dim = 1)
x |
an array |
dim |
dimension(s) along which to flip (in sequence), defaults to 1 (i.e. flip rows). |
The array x
having the dim
dimension flipped.
Tomas Sieger
# flip a matrix
x<-matrix(1:6,2)
x
# flip upside down
flip(x,1)
# flip left to right
flip(x,2)
# flip both upside down and left to right
flip(x,1:2)
# flip a vector
v<-1:10
v
flip(v)
# flip an array
a<-array(1:prod(2:4),2:4)
a
# flip along dim 1
flip(a,1)
# flip along dim 2
flip(a,2)
# flip along dim 3
flip(a,3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.