diff --git a/man/shift.Rd b/man/shift.Rd index 7815b3284..35268411e 100644 --- a/man/shift.Rd +++ b/man/shift.Rd @@ -29,7 +29,7 @@ shift(x, n=1L, fill, type=c("lag", "lead", "shift", "cyclic"), give.names=FALSE) Note that when using \code{shift} with a list, it should be a list of lists rather than a flattened list. The function was not designed to handle flattened lists directly. This also applies to the use of list columns in a data.table. For example, \code{DT = data.table(x=as.list(1:4))} is a data.table with four rows. Applying \code{DT[, shift(x)]} now lags every entry individually, rather than shifting the full columns like \code{DT[, shift(as.integer(x))]} does. Using \code{DT = data.table(x=list(1:4))} creates a data.table with one row. Now \code{DT[, shift(x)]} returns a data.table with four rows where x is lagged. To get a shifted data.table with the same number of rows, wrap the \code{shift} function in \code{list} or \code{dot}, e.g., \code{DT[, .(shift(x))]}. } \value{ - A list containing the lead/lag of input \code{x}. + When \code{x} is a vector and \code{length(n) == 1}, a vector of the same type and length as \code{x}. Otherwise, a list of vectors (one element for each combination of input column and \code{n} value). } \examples{