lagXts: Lag an xts Object

Description Usage Arguments Value Examples

View source: R/Functions.R

Description

1
2
3
This does not complain when: any(abs(k) > NROW(xTs)):
zoo_lag can not and will not handle. So k's are eliminated
beforehand.

Usage

1
lagXts(x, k = 1, na.pad = TRUE, ...)

Arguments

x

xts object

k

choose -1 to look into the future

na.pad

as lag.xts

...

dots passed to lag.xts

Value

xts object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## Not run: 

xts(1:4, zoo::as.Date(0:3))
           [,1]
1970-01-01    1
1970-01-02    2
1970-01-03    3
1970-01-04    4

lagXts(xts(1:4, zoo::as.Date(0:3)), k =  c(-5:-3,0:1,3:5))
           V1lead.4 V1lead.3 V1lag.0 V1lag.1 V1lag.3 V1lag.4
1970-01-01       NA        4       1      NA      NA      NA
1970-01-02       NA       NA       2       1      NA      NA
1970-01-03       NA       NA       3       2      NA      NA
1970-01-04       NA       NA       4       3       1      NA

xts(matrix(1:4,ncol =2), zoo::as.Date(0:1))
           [,1] [,2]
1970-01-01    1    3
1970-01-02    2    4

lagXts(xts(matrix(1:4,ncol =2), zoo::as.Date(0:1)), k =  c(-5:-3,0:1,3:5))
           V1lag.0 V2lag.0 V1lag.1 V2lag.1
1970-01-01       1       3      NA      NA
1970-01-02       2       4       1       3



## End(Not run)

AndreMikulec/econModel documentation built on June 30, 2021, 9:48 a.m.