character string is not in a standard unambiguous format even after all conversion

I have tried most of the things that I could, why is it not working then...

library(dygraphs)
library(xts)
library(lubridate)
library(timetk)
library(dplyr)
library(readr)

data1<-tibble::tribble(
           ~month, ~abortion, ~delivery, ~pregnant,
         "Jan-17",        13,        30,        43,
         "Feb-17",        40,        14,        54,
         "Mar-17",        19,        15,        34,
         "Apr-17",        45,        20,        65,
         "May-17",        16,        60,        76,
         "Jun-17",        10,        35,        45,
         "Jul-17",        10,        55,        65,
         "Aug-17",        17,        70,        87,
         "Sep-17",        10,        88,        98,
         "Oct-17",        18,        60,        78,
         "Nov-17",        25,        40,        65,
         "Dec-17",        30,        37,        67,
         "Jan-18",        30,        26,        56,
         "Feb-18",        25,        20,        45,
         "Mar-18",        20,        14,        34,
         "Apr-18",        30,        24,        54,
         "May-18",        20,        45,        65,
         "Jun-18",        10,        57,        67,
         "Jul-18",        10,        88,        98,
         "Aug-18",        60,        18,        78,
         "Sep-18",        30,        35,        65,
         "Oct-18",        30,        37,        67,
         "Nov-18",        10,        46,        56,
         "Dec-18",        20,        45,        65,
         "Jan-19",        10,        35,        45,
         "Feb-19",        10,        24,        34,
         "Mar-19",        30,        35,        65,
         "Apr-19",        40,        25,        65,
         "May-19",        40,        48,        88
         )

str(data1)
#s<-parse_datetime(data1$month, "%d/%m/%y")
#s<-as.Date(data1$month)
s<-as.POSIXct(as.numeric(as.character(data1$month)),origin = "2017-01-01")
s
qxts <- xts(data1[, -1], order.by=as.POSIXct(data1$month))
ad <- cbind(data1$abortion,data1$delivery,data1$pregnant)
dygraph(ad, main = "Deaths from Lung Disease (UK)") %>%
  dySeries("abortion", stepPlot = TRUE, color = "red") %>%
  dyGroup(c("delivery", "pregnant"), drawPoints = TRUE, color = c("blue", "green"))

I have got it,it was not conversion it was wrong data passing.

library(dygraphs)
library(xts)
library(lubridate)
library(timetk)
library(dplyr)
library(readr)

data1<-tibble::tribble(
               ~month, ~abortion, ~delivery, ~pregnant,
         "01-01-2017",        13,        30,        43,
         "01-02-2017",        40,        14,        54,
         "01-03-2017",        19,        15,        34,
         "01-04-2017",        45,        20,        65,
         "01-05-2017",        16,        60,        76,
         "01-06-2017",        10,        35,        45,
         "01-07-2017",        10,        55,        65,
         "01-08-2017",        17,        70,        87,
         "01-09-2017",        10,        88,        98,
         "01-10-2017",        18,        60,        78,
         "01-11-2017",        25,        40,        65,
         "01-12-2017",        30,        37,        67,
         "01-01-2018",        30,        26,        56,
         "01-02-2018",        25,        20,        45,
         "01-03-2018",        20,        14,        34,
         "01-04-2018",        30,        24,        54,
         "01-05-2018",        20,        45,        65,
         "01-06-2018",        10,        57,        67,
         "01-07-2018",        10,        88,        98,
         "01-08-2018",        60,        18,        78,
         "01-09-2018",        30,        35,        65,
         "01-10-2018",        30,        37,        67,
         "01-11-2018",        10,        46,        56,
         "01-12-2018",        20,        45,        65,
         "01-01-2019",        10,        35,        45,
         "01-02-2019",        10,        24,        34,
         "01-03-2019",        30,        35,        65,
         "01-04-2019",        40,        25,        65,
         "01-05-2019",        40,        48,        88
         )
#d1<-aggregate(. ~data1$month,data = data1,sum)
#s<-parse_datetime(data1$month, "%d/%m/%y")
#s<-as.Date(data1$month)
# s<-as.POSIXct(as.numeric(as.character(data1$month)),origin = "2017-01-01")
# s
qxts <- xts(data1[, -1], order.by=as.POSIXct(data1$month))
ad <- cbind(qxts$abortion,qxts$delivery,qxts$pregnant)
dygraph(ad, main = "Deaths from Lung Disease (UK)") %>%
  dySeries("abortion", stepPlot = TRUE, color = "red") %>%
  dyGroup(c("delivery", "pregnant"), drawPoints = TRUE, color = c("blue", "green"))

This topic was automatically closed 7 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.