Last active
April 29, 2021 11:14
-
-
Save RamiKrispin/a3cb7491d09efff1abada9a671355e09 to your computer and use it in GitHub Desktop.
Covid19 Death Dist Plot
This file contains hidden or 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
| library(coronavirus) | |
| library(dplyr) | |
| library(plotly) | |
| df <- refresh_coronavirus_jhu() | |
| head(df) | |
| df1 <- df %>% | |
| filter(data_type == "deaths_new") %>% | |
| group_by(location) %>% | |
| summarise(total = sum(value), | |
| .groups = "drop") %>% | |
| arrange(-total) %>% | |
| mutate(parent = "", | |
| perc = total / sum(total), | |
| cum = cumsum(perc)) | |
| head(df1) | |
| plot_ly( | |
| data = df1, | |
| type = 'treemap', | |
| labels = ~ location, | |
| parents = ~ parent, | |
| values = ~ total, | |
| textinfo = "label+value+percent parent+percent", | |
| domain = list(column=0)) %>% | |
| layout(title = "Distribution of Covid19 Deaths Around the World", | |
| font = list(size = 20, | |
| family = "Arieal"), | |
| annotations = list(text = "Source: Johns Hopkins University Center for Systems Science and Engineering", | |
| x = 0.01, | |
| y = -0.02, | |
| font = list(size = 14), | |
| xref = "paper", | |
| yref = "paper", | |
| showarrow = FALSE), | |
| margin = list(t = 50, b = 20, l = 10, r = 10, pad = 4)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment