move

Syntax

move(X, steps)

Details

Shifts X one position to the left or right. This function is a generalized form of prev and next.

Parameters

X is a vector/matrix/table.

steps is an integer indicating how many positions to shift the elements of X.
  • If steps is positive, X is moved to the right for steps positions;
  • If steps is negative, X is moved to the left for steps positions;
  • If steps is 0, X does not move;
  • If steps is a DURATION, X must be an indexed matrix or indexed series with temporal values as its row index. For each timestamp Ti with value Xi, the shifted result is determined as follows: Find the value corresponding to time Tisteps on the timeline and assign it to the current position.
    • If a timestamp exactly equal to Tisteps exists, use the value at that timestamp.
    • If no such timestamp exists, use the value at the largest timestamp that is not later than Tisteps.
    • If no timestamp satisfies the condition, the result is NULL.

Returns

Returns an object with the same type and form as X.

Examples

x=3 9 5 1 4 9;
move(x,3);
// output: [,,,3,9,5]

move(x,-2);
// output: [5,1,4,9,,]

index = (second(08:20:00)+1..4) join 08:21:01 join 08:21:02
x = index.indexedSeries(x)
move(x,3s)
label col1
08:20:01
08:20:02
08:20:03
08:20:04 3
08:21:01 1
08:21:02 1
move(x,1m)
label col1
08:20:01
08:20:02
08:20:03
08:20:04
08:21:01 3
08:21:02 9