lag.df: lag.df

Description Usage Arguments Value Author(s) Examples

View source: R/pub01_utilityFuncs.R

Description

Methods for computing lags of data frame objects.

Usage

1
lag.df(df, k = 1, na.pad = FALSE)

Arguments

df

a data frame object

k

the number of lags (in units of observations).Note the sign of k: a series lagged by a positive k is shifted earlier,and a negtive k is shifted later.

na.pad

logical. If TRUE it adds any rows that would not otherwise have been in the result with a value of NA. If FALSE those rows are dropped.

Value

a data frame object

Author(s)

Ruifei.yin

Examples

1
2
3
4
5
6
7
m <- matrix(1:10,5,2)
rownames(m) <- letters[1:5]
colnames(m) <- LETTERS[1:2]
df <- as.data.frame(m)
lag.df(df,1)
lag.df(df,-1)
lag.df(df,1,TRUE)

QuantAndrew/QUtility documentation built on May 14, 2019, 7:36 a.m.