Skip to content
Prev 295801 / 398502 Next

Query about creating time sequences

Try this:

# Setting TZ is optional, but I find it helps me to be more aware of 
# timezone effects
Sys.setenv( TZ="Asia/Kolkata")
library(lubridate)

pdates <- as.POSIXct( fdates )
hstart <- new_period( hour=9, minute=15 )
hend <- new_period( hour=15, minute=30 )
mperiod <- new_period( minute=15 )
numperday <- (hend-hstart)/mperiod
dtms <- expand.grid( dt=pdates, tm=hstart + mperiod * seq( from=0, 
to=numperday ) )
dtms$dtm <- with( dtyms, dt + tm )
dtms <- dtms[ order( dtms$dtm ), ]

You can discard everything but dtms$dtm once it has been created.
On Mon, 28 May 2012, Shivam wrote:

            
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k