Description Usage Arguments Value Author(s) References Examples
Shift function allows one to either lag or lead a column variables in a data frame.
1 |
x |
is a variable to be lagged or leaded. |
delta |
an integer value as positive (#) or negative (-#). |
An object of the same type as x
.
Daniel Marcelino
http://danielmarcelino.com/SciencePo
1 2 3 4 5 6 7 8 9 | montreal <- data.frame(
month = a <- c('J','F','M','A','M','J','J','A','S','O','N','D'),
precip = b <- c(78,62,74,78,76, 83, 91, 93, 93,78, 93, 81),
max = c <- c(-6, -4, 2, 11, 19, 24, 26, 25, 20, 13, 5, -2),
min = d <- c(-15, -13, -7, 1, 8, 13, 16, 14, 9, 3, -2, -10) )
(montreal$L.precip <- shift(montreal$precip, -1) )
(montreal$precip.L <- shift(montreal$precip, 1) )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.