-
Notifications
You must be signed in to change notification settings - Fork 631
Closed
Description
One more for you... In the Nunavut panel (bottom right) - the data begins only at 2003 (unlike the other provinces that begin at 2002), but for some reason the confidence band extends to cover 2002 even though there is no data at 2002 in Nunavut.
Here's the code for you. The ggplot is called plot1 and the plotly version is called gg2. Thanks!
library(ggplot2)
library(scales)
library(grid)
library(dplyr)
library(plotly)
dat <- read.csv("http://corinne-riddell.github.io/datasets/CS_graph.csv")
dat$ucl2 <- as.numeric(as.character(dat$ucl))
dat$lcl2 <- as.numeric(as.character(dat$lcl))
order <- dat %>% group_by(Label) %>% dplyr::summarise(Code=first(Code))
dat$CS2 <- dat$CS/100
dat$Lab2 <- factor(dat$Label, levels=c("Canada","Newfoundland and Labrador",
"Prince Edward Island","Nova Scotia",
"New Brunswick", "Quebec", "Ontario",
"Manitoba", "Saskatchewan", "Alberta",
"British Columbia", "Yukon Territory",
"Northwest Territories", "Nunavut"
))
plot1 <- ggplot(dat, aes(x=Year, y=CS2)) + geom_ribbon(aes(ymin=lcl2/100, ymax=ucl2/100), col="#f0f0f0", alpha=0.5) +
geom_point() + geom_line(lwd=0.5) + facet_wrap(~Lab2, ncol=4) +
theme_minimal(base_size=15) + scale_y_continuous(labels=percent, name="Cesarean delivery rate (%)\n") +
scale_x_continuous(name="\nYear") + theme(panel.border = element_rect(fill=NA))
plot1
gg2 <- ggplotly(plot1)
gg2
Metadata
Metadata
Assignees
Labels
No labels