[R] Time format lagging issue

Bhaskar Mitra
Wed, 31 Aug 2016 16:07:49 -0000

Hello Everyone,

I am trying a shift the time series in a dataframe (df) by 30 minutes . My
current format looks something like this :



*df$$Time 1*


*201112312230*

*201112312300*

*201112312330*



*I am trying to add an additional column of time (df$Time 2) next to  Time
1 by lagging it by ? 30minutes. Something like this :*


*df$Time1                   **df$$Time2*


*201112312230          **201112312200*

*201112312300          **201112312230*

*201112312330          **201112312300*

*201112312330          *





*Based on some of the suggestions available, I have tried this option *



*require(zoo)*

*df1$Time2  <- lag(df1$Time1, -1, na.pad = TRUE)*

*View(df1)*



*This does not however give me the desired result. I would appreciate any
suggestions/advice in this regard.*


*Thanks,*

*Bhaskar*