I am having difficulty in plotting moving average using the R dygraph package using DyRoller. As per the documentation, I should be able to plot moving average by entering a value in the lower window. However on entering any value for moving average above 1, I get an empty plot. Figure below shows the issue:
Below is the sample code for reproducing the problem:
require(xts)
require(dygraphs)
startDate = as.POSIXct("2013-12-23 9:30:00")
endDate = as.POSIXct("2013-12-23 16:00:00")
dateSeq5sec = seq(from=startDate, to=endDate, by="5 sec")
data <- rnorm(4681,6,1)
my_data <- data.frame(dateSeq5sec,data)
my_data <- xts(my_data,order.by = my_data$dateSeq5sec)
dygraph(my_data, main = "Important Discoveries") %>%
dyRoller(showRoller = TRUE, rollPeriod = 1)
I think you are looking for this:
dygraph( xts(x = data, order.by = dateSeq5sec) ) %>%
dyRoller(showRoller = TRUE, rollPeriod = 1)