Lead or lag vectors or lists.

shift(x, n = 1L, type = "lag")

Arguments

x

a vector or list.

n

an integer denoting the offset by which to lead or lag the input. This function only supports n>=0.

type

Default is "lead" (look "forwards"). The other possible value is "lag" (look "backwards").

Value

An object with the same class as x that contains the lead/lag of input x.