Wrong data type while using dygraph R

dygraphs

#1

I have a dataframe which I am trying to plot using dygraph. Below is the data and the code . It throws an error in regards to the input data.

Unsupported type passed to argument 'data'.

> data
   Month_considered    pct.x    pct.y      pct
1        2017-04-01 79.01806 18.37270 2.609233
2        2017-05-01 78.92630 18.08007 2.993631
3        2017-06-01 77.85767 18.71959 3.422741
4        2017-07-01 77.62186 18.53547 3.842667
5        2017-08-01 77.99165 18.30980 3.698548
6        2017-09-01 77.97691 18.86093 3.162158
7        2017-10-01 77.60254 18.91230 3.485157
8        2017-11-01 77.58103 18.41126 4.007711
9        2017-12-01 78.51329 18.02403 3.462681
10       2018-01-01 79.29935 18.39552 2.305134
11             <NA> 78.90468 19.61910 1.476217

dy <-as.data.frame(delta)
   dygraph(data) %>%
     dySeries("pct", label = "Male") %>%
  
     dyOptions(stackedGraph = TRUE) %>%
     dyRangeSelector(height = 20)

#2

Hi,

dygraphs only works with xts time series objects (or any object convertible to xts) as the documentation suggest.

Converting the data.frame into a xts object should solve the issue.

Regards,