Skip to content

Replacing dates with consecutive observations

3 messages · Alina Sheyman, Indrajit Sengupta, Henrique Dallazuanna

#
Hi Alina,
?
You can always write a loop in R to do this:

# A function to shift values in an vector
shift = function(y) {
?cnt = length(y) - 1
?m=vector(mode = "numeric",length = cnt)?
?for (j in 1:cnt) {
?m[j] = y[j+1]}
?m
}
?
Regards,

Indrajit