[R] Chron object in time series plot
Phil Spector
spector at stat.berkeley.edu
Tue Oct 19 19:30:57 CEST 2010
The following will create a POSIXlt object using the current date:
> strptime(sprintf('%06d',breaks),'%H%M%S')
[1] "2010-10-19 07:00:00" "2010-10-19 07:15:00" "2010-10-19 07:30:00"
[4] "2010-10-19 07:45:00" "2010-10-19 08:00:00" "2010-10-19 08:15:00"
[7] "2010-10-19 08:30:00" "2010-10-19 08:45:00" "2010-10-19 09:00:00"
. . .
To get just the hours and minutes, you could use
> format(strptime(sprintf('%06d',breaks),'%H%M%S'),'%H:%M')
[1] "07:00" "07:15" "07:30" "07:45" "08:00" "08:15" "08:30" "08:45" "09:00"
[10] "09:15" "09:30" "09:45" "10:00" "10:15" "10:30" "10:45" "11:00" "11:15"
. . .
And I'm still not sure I've answered your question.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Tue, 19 Oct 2010, Manta wrote:
>
> I do not think that importing the time as character will help me, as I need
> to perform several operation with them. Again, maybe I am not able to
> express clearly enough. Let's just focus on this series:
>
>> breaks
> [1] 70000 71500 73000 74500 80000 81500 83000 84500 90000 91500
> 93000 94500 100000 101500 103000 104500
> [17] 110000 111500 113000 114500 120000 121500 123000 124500 130000 131500
> 133000 134500 140000 141500 143000 144500
> [33] 150000 151500 153000 154500 160000 161500 163000 164500 170000 171500
> 173000 174500 180000 181500 183000 184500
>
> I want a simple function that can convert breaks into a treatable object by
> 'zoo' as follows:
>
> [1] 07:00 07:15 07:30 ....
> ..
> [33]...
> 18:00 18:15 18:30 18:45
>
> Is this possible?
> --
> View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3002458.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list