Skip to content

Instantly share code, notes, and snippets.

@RamiKrispin
Created April 29, 2020 15:48
Show Gist options
  • Save RamiKrispin/5250d62f0a650e7d469d9b28b8ffe567 to your computer and use it in GitHub Desktop.
Save RamiKrispin/5250d62f0a650e7d469d9b28b8ffe567 to your computer and use it in GitHub Desktop.
# Creating a tree-map plot for the total covid19 confirmed cases in Italy
#------------------------------------------------------------------------
# Required packages
library(covid19italy)
library(dplyr)
library(plotly)
# Check for updates
update_data()
#if updates available you will have to restart your session and reload the covid19italy package
# Get the most recent data
conf_cases <- italy_province %>%
filter(date == max(date)) %>%
select(province_name, total_cases) %>%
mutate(parents = "Confirmed")
# Create a treemap for the confirmed cases by province
plot_ly(data = conf_cases,
type= "treemap",
values = ~total_cases,
labels= ~ province_name,
parents= ~parents,
domain = list(column=0),
name = "Confirmed",
textinfo="label+value+percent parent") %>%
layout(title = "Covid19 Italy - Confirmed Cases Distribution by Province")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment