shift | R Documentation |
Shift a vector left or right n spaces.
shift(x, n, direction = "right")
shift_right(x, n)
shift_left(x, n)
x |
A vector. |
n |
The number of moves left or right to shift. |
direction |
A direction to shift; must be either "left" or "right".
Use explicit directional shift functions |
Returns a shifted vector.
lapply(0:9, function(i) shift(1:10, i))
lapply(0:9, function(i) shift(1:10, i, "left"))
## Explicit, faster shifting
lapply(0:9, function(i) shift_right(1:10, i))
lapply(0:9, function(i) shift_left(1:10, i))
lapply(0:25, function(i) shift_left(LETTERS, i))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.