Reputation: 729
First, I am not a pro in R and I have difficulties to manage date and time series, I would appreciate any advices like tutorials on this topic that I may find on the web.
I would like to plot a dygraph of a time serie here is my code
library(lubridate)
library(dygraphs)
library(zoo)
library(xts)
#the data
data1<-rnorm(105120)
##data between 2014-01-01 and 2014-12-31 every five minute
d1<-seq(as.POSIXct("2014-01-01 00:00:00"), as.POSIXct("2014-12-31 23:59:00"), by=300)
#data frame
df <- data.frame(cbind(d1, data1))
Then
#time serie
ts1<-ts(df[,2], start=0,end=365*24,frequency=60/5)
I don't know How to define a time serie between two date??
some tests I try with help on the web
##test
z1 <- as.zoo(ts1)
z1xts <- xts(z1 , date_decimal(index(z1)))
Dygraphs tests but none of it works
##test dygraph
dygraph(df) %>% dyRangeSelector()
dygraph(ts1) %>% dyRangeSelector()
dygraph(z1xts) %>% dyRangeSelector()
Upvotes: 0
Views: 1303
Reputation: 1035
Here is the answer:
dygraph( xts(x = data1, order.by = d1) ) %>%
dyRangeSelector()
Please read ?xts
Upvotes: 2