On Fri, 09 Aug 2013, Manta mantin...@libero.it writes:
Dear all,
I have a problem which I'm not to fix. I have the following two series:
a=structure(c(33242.5196150509, 34905.8434338503, 38490.6957848689,
38747.0287172129, 38919.1028597142, 39026.3956586941, 38705.5344288997,
38545.6274379387, 38651.2079354205, 38748.2769580121), index =
structure(c(14029,
14032, 14033, 14034, 14035, 14036, 14039, 14040, 14041, 14042
), class = Date), class = zoo)
b=structure(c(53337.7643740991, 52210.2079727035, 50235.4480363949,
50667.1147389469, 50796.5403152116, 51113.5420947436, 51003.3603311344,
50654.0539778796, 49927.5267060329, 49320.1813921822), index =
structure(c(14029,
14032, 14033, 14034, 14035, 14036, 14039, 14040, 14041, 14042
), class = Date), class = zoo)
I want to plot them on the same chart, with the x-axis the Date, and the
y-axis the time in format %H:%M. At the moment, the y series is expressed in
seconds from midnight. I am confused with the as.POSIXct conversion.
hours(min(rollrep))
[1] 9
minutes(min(rollrep))
[1] 34
seconds(min(rollrep))
[1] 27
however, by doing the following it seems the minimum time is 11:09, which is
not true.
as.POSIXct(round(min(rollrep)),origin=Sys.Date())
[1] 2013-08-09 11:09:14 CEST
Do you have any advice? Is there a way to plot only the hours and minutes,
without having to go to the Sys.Date?
Thank you,
Marco
Please provide a *reproducible* example. (What is 'rollrep'? 'Seconds
from midnight' may be ambiguous when there was a change to/from
summertime or when time zones are relevant.)
Perhaps something like this:
require(zoo)
plot(merge(a, b), plot.type = single, yaxt = n)
midnight - ISOdatetime(2013, 1, 1, 0, 0, 0, GMT)
sq - seq(0, 86400, by = 300)
axis(2, at = sq, labels = format(midnight + sq, %H:%M))
--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net
__
R-help@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.