Created
February 29, 2020 16:48
-
-
Save RamiKrispin/9e1e29ce946cd2571dc7b8c38c9e60a4 to your computer and use it in GitHub Desktop.
Creating dist plot for China province
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
province_vec <- coronavirus %>% | |
dplyr::filter(type == "confirmed", Country.Region == "Mainland China") %>% | |
dplyr::group_by(Province.State) %>% | |
dplyr::summarise(total = sum(cases, na.rm = TRUE)) %>% | |
dplyr::arrange(-total) %>% | |
dplyr::select(province = Province.State) | |
coronavirus %>% | |
dplyr::filter(type == "confirmed", Country.Region == "Mainland China") %>% | |
dplyr::group_by(date, Province.State) %>% | |
dplyr::summarise(total = sum(cases, na.rm = TRUE)) %>% | |
dplyr::ungroup() %>% | |
dplyr::mutate(province = Province.State) %>% | |
dplyr::mutate(province = factor(province, levels = province_vec$province)) %>% | |
plotly::plot_ly( | |
type = "scatter", | |
x = ~ date, y = ~ total, | |
color = ~ province, | |
mode = "lines", | |
fill = "tonexty", | |
groupnorm = 'percent', | |
stackgroup = 'one') %>% | |
plotly::layout(title = "", | |
xaxis = list(title = "", | |
showgrid = FALSE), | |
yaxis = list(title = "", | |
showgrid = FALSE, | |
ticksuffix = '%', | |
hoverformat = '.2f')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment