Shift function

Share:

Description

This function shifts a vector input a certain number of places in the direction desired.

Usage

1
shift(v, places, dir = "right")

Arguments

v

a vector of input values.

places

the number of places to shift v.

dir

The direction to shift v.

Details

The function shifts the vector v by places in the direction of direction, using wrapping at the boundaries. Used for cycle spinning.

Value

vnew

the shifted version of v.

Author(s)

Matt Nunes (m.nunes@ucl.ac.uk)

Examples

1
2
3
4
5
6
7
8
9
v<-runif(10)

#have a look at v:

v

#now shift the values 4 places to the right...

shift(v,4,dir="right")