[R] Time format lagging issue

Bhaskar Mitra bhaskar.kolkata at gmail.com
Wed Aug 31 18:07:49 CEST 2016


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*

	[[alternative HTML version deleted]]



More information about the R-help mailing list