Unsupported type passed to argument 'data'

library(dygraphs)
library(timetk)
library(xts)
df<-tibble::tribble(
        ~month, ~abortion, ~delivery, ~pregnant,
      "01-01-17",        13,        30,        43,
      "01-02-17",        40,        14,        54,
      "01-03-17",        19,        15,        34,
      "01-04-17",        45,        20,        65,
      "01-05-17",        16,        60,        76,
      "01-06-17",        10,        35,        45,
      "01-07-17",        10,        55,        65,
      "01-08-17",        17,        70,        87,
      "01-09-17",        10,        88,        98,
      "01-10-17",        18,        60,        78,
      "01-11-17",        25,        40,        65,
      "01-12-17",        30,        37,        67,
      "01-01-18",        30,        26,        56,
      "01-02-18",        25,        20,        45,
      "01-03-18",        20,        14,        34,
      "01-04-18",        30,        24,        54,
      "01-05-18",        20,        45,        65,
      "01-06-18",        10,        57,        67,
      "01-07-18",        10,        88,        98,
      "01-08-18",        60,        18,        78,
      "01-09-18",        30,        35,        65,
      "01-10-18",        30,        37,        67,
      "01-11-18",        10,        46,        56,
      "01-12-18",        20,        45,        65,
      "01-01-19",        10,        35,        45,
      "01-02-19",        10,        24,        34,
      "01-03-19",        30,        35,        65,
      "01-04-19",        40,        25,        65,
      "01-05-19",        40,        48,        88
      )

# t <- xts(x=d1,order.by = d1$MthYr)
report <- cbind(df$abortion, df$delivery,df$pregnant)
dygraph(report)
dygraph(report) %>% dyRangeSelector()

could anyone guide me through how to get rid of this error

report is not in the form required by the dygraph function

data
Either time series data or numeric data. For time series, this must be an xts object or an object which is convertible to xts. For numeric data, this must be a named list or data frame, where the first element/column provides x-axis values and all subsequent elements/columns provide one or more series of y-values.

main
Main plot title (optional)

xlab
X axis label

ylab
Y axis label

periodicity
Periodicity of time series data (automatically detected via xts::periodicity if not specified).

group
Group to associate this plot with. The x-axis zoom level of plots within a group is automatically synchronized.

elementId
Use an explicit element ID for the widget (rather than an automatically generated one). Useful if you have other JavaScript that needs to explicitly discover and interact with a specific widget instance.

width
Width in pixels (optional, defaults to automatic sizing)

height
Height in pixels (optional, defaults to automatic sizing)

I have tried all the things given in the documentation , why is it not working then.
could you please tell me specifically what should I do to pass the error.

library(dygraphs)
library(xts)          # To make the convertion data-frame / xts format
 
# Create data 
data <- data.frame(
  time=seq(from=Sys.Date()-40, to=Sys.Date(), by=1 ), 
  value=runif(41)
)

# Double-check time is at the date format
str(data$time)

# Switch to XTS format
data <- xts(x = data$value, order.by = data$time)
 
# Default = line plot --> See chart #316
 
# Add points
p <- dygraph(data) %>%
  dyOptions( drawPoints = TRUE, pointSize = 4 )
p

I referred to this example but couldn't convert my time into the desired format.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.