I'm trying to plot time series with the dygraph
function. A single diagram represents the course of a specific variable on different days. Since series correspond to different days, I would like the x-axis to be date-agnostic. It should only contain time-intervals.
When I generate a time sequence with:
ts <- seq(as.POSIXct("2017-01-01 00:00:00"),as.POSIXct("2017-01-01 23:30:00"), by = "30 min")
and make a plot using it:
d <- data.frame(
time = ts,
profile1 = ...,
profile2 = ...,
profile3 = ...
)
don=xts(x=d[,c("profile1", "profile2", "profile3")], order.by=d$time)
I obtain a date used for creating the time sequence on the axis, which is not desirable:
I combed through the SO, looking for a method to obtain only time intervals from dates but presented methods do not help - results are rejected by the order.by
component of the xts(...)
function.
I have tried the following (ts
is the sequence defined above):
strftime(ts, format = "%H:%M:%S")
-> Error:order.by requires an appropriate time-based object
chron
ts <- chron(times. = ts)
Error in convert.times(times., fmt) : format h:m:s may be incorrect
Additionaly: Warning:
In convert.times(times., fmt) : NAs obtained
- 1 & 2 combined:
ts <- strftime(ts, format = "%H:%M:%S")
ts <- chron(times. = ts)
Fehler in as.POSIXct.default(order.by) :
do not know how to convert 'order.by' to class “POSIXct”
Moreover, I would like the x-axis to be formatted in such a way that it shows the timespan between 00:00 to 00:00 if possible. Right now, as you can see in the picture, it starts with a date and ends without any interval info, there is just an empty space there.