it is plotting the wrong graph since the data is not parsed or converted in the correct format. I don't know what I am missing here, is it bcoz of wrong parsing or something else. please help me to rectify this error.
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
)
str(data1)
glimpse(data1)
# a<-data1 %>% group_by(data1$month)
# a
aggregate(. ~month, data=data1, FUN = 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.Date(as.POSIXct(data1$month)))
qxts
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"))
what it is looking after conversion...
abortion delivery pregnant
0001-01-19 13 30 43
0001-01-19 30 26 56
0001-01-19 10 35 45
0001-02-19 40 14 54
0001-02-19 25 20 45
0001-02-19 10 24 34
0001-03-19 19 15 34
0001-03-19 20 14 34
0001-03-19 30 35 65
0001-04-19 45 20 65
0001-04-19 30 24 54
0001-04-19 40 25 65
0001-05-19 16 60 76
0001-05-19 20 45 65
0001-05-19 40 48 88
0001-06-19 10 35 45
0001-06-19 10 57 67
0001-07-19 10 55 65
0001-07-19 10 88 98
0001-08-19 17 70 87
0001-08-19 60 18 78
0001-09-19 10 88 98
0001-09-19 30 35 65
0001-10-19 18 60 78
0001-10-19 30 37 67
0001-11-19 25 40 65
0001-11-19 10 46 56
0001-12-19 30 37 67
0001-12-19 20 45 65
while the real data are given in the tribble above.
could anyone tell me how to rectify this error, any help or suggestion would be a great help.
Thanks