Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequence of time(hour)

I tried:

seq(
     from=as.POSIXct("2012-1-1 0", tz="UTC"),
     to=as.POSIXct("2012-1-3 23", tz="UTC"),
     by="hour"
   )  

But I only get 1 hour(0:00:00) of the last day instead of 24 hours, actually any hour of the day resulted in only one hour(0:00:00), and I do want to have 2012-1-4.

like image 799
Rosa Avatar asked Aug 20 '12 02:08

Rosa


2 Answers

Specify the time in full?

seq(
     from=as.POSIXct("2012-1-1 0:00", tz="UTC"),
     to=as.POSIXct("2012-1-3 23:00", tz="UTC"),
     by="hour"
   )  
like image 67
thelatemail Avatar answered Sep 17 '22 14:09

thelatemail


You did not use a standard format for the dates. See ?as.POSIXct.

Try this

seq(from=as.POSIXct("2012-01-01 00:00:00", tz="UTC"), 
    to=as.POSIXct("2012-01-03 23:00:00", tz="UTC"), by="hour")
like image 29
GSee Avatar answered Sep 18 '22 14:09

GSee