lag.m: lag.m

Description Usage Arguments Value Author(s) Examples

View source: R/pub01_utilityFuncs.R

Description

Methods for computing lags of matrix or vector objects.

Usage

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

Arguments

m

a matrix or a vector

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 matirx or a vector

Author(s)

Ruifei.yin

Examples

1
2
3
4
5
6
7
8
m <- matrix(1:10,5,2)
rownames(m) <- letters[1:5]
colnames(m) <- LETTERS[1:2]
lag.m(m,1)
lag.m(m,-1)
lag.m(m,1,TRUE)
v <- c(a=1,b=2,c=3,d=4)
lag.m(v,-2,TRUE)

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