computeLag: Moves cases of variables

Description Usage Arguments Details Value Author(s) Examples

View source: R/xpssLag.R

Description

computeLag shifts the dataset forward or backward by a given number of observations.

Usage

1
computeLag(x, move = 0, value = NA)

Arguments

x

a (non-empty) data.frame, data.table object or input data of class "xpssFrame".

move

atomic integer, either positive or negative that defines the cases to move. The algebraic sign indicates the direction.

value

atomic numeric or atomic character value that replaces the skipped cases.

Details

Creates shifted data dependent upon the direction in which the data got moved.
A positive indicator refers a shift to the right side, a negative indicator refers a shift of the data to the left side. Empty cases get filled with NA.

Value

Output is the shifted, respectively "lagged" input vector.
Length of the new lagged vector is identical with the length of the input vector.

Author(s)

Andreas Wygrabek

Examples

1
2
data(fromXPSS)
computeLag(x=fromXPSS$V6, move = 2, value = NA)

translateSPSS2R documentation built on May 30, 2017, 4:31 a.m.