File:Wiki covid andorra4.png

From WikiMD's medical encyclopedia

Original file(4,800 × 2,400 pixels, file size: 101 KB, MIME type: image/png)

This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

Summary

Description
English: Cumulative COVID-19 cases confirmed in Andorra
Date
Source Own work
Author GeneParmesan66

Below is the R code used to generate this plot. It is modified from another script that pulls each case type file from Johns Hopkins so some of the organization is unnecessary.

   # Libraries
   library(extrafont)
   library(tidyverse)
   library(janitor)
   library(here)
   library(lubridate)
   library(ggtext)
   library(ggrepel)
   
   # COVID Case Data ---------------------------------------------------------
   
   
   folder_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/"
   
   # files = c("confirmed", "recovered", "deaths")
   
   
   # Because each file is in the folder, paste together the filenames
   case_urls = str_c(folder_url, 
                     # e.g. time_series_covid19_confirmed_global.csv
                     "time_series_covid19_", "confirmed", "_global.csv") %>% 
     # Setting names so we can map over each file later
     # set_names(files)
     set_names("confirmed")
   
   
   covid_data = imap_dfr(case_urls, 
                         ~read_csv(file = .x), 
                         .id = "case_type") %>% 
     select(`Province/State`, `Country/Region`, case_type, everything()) %>% 
     filter(`Country/Region` == "Andorra")
   
   covid_pivot = covid_data %>% 
     pivot_longer(cols = c(-1:-5), 
                  names_to = "date", values_to = "total_cases",
                  names_transform = list(date = mdy)) %>% 
     clean_names()
   
   
   # Make labels for the end of each quarter
   quarterly_labels = covid_pivot %>% 
     group_by(quarter(date, with_year = T)) %>% 
     filter(date == max(date))
   
   
   # Plotting ---------------------------------------------------------
   
   
   line_graph = covid_pivot %>% 
     ggplot(., aes(x = date, y = total_cases))+
     geom_line(colour = "#1f77b4", size = 1.3)+
     geom_text(data = quarterly_labels, 
               aes(label = scales::comma(total_cases)), 
               size = 6, colour ="#202122",
               family = "Arial",nudge_x = -9, nudge_y = 280)+
     scale_y_continuous(labels = scales::comma, 
                        expand = expansion(add = c(25,0)))+
     scale_x_date(date_breaks = "2 months", date_labels = "%b %y", 
                  expand = expansion())+
     coord_cartesian(xlim = range(covid_pivot$date), 
                     ylim = range(covid_pivot$total_cases), 
                     clip = "off")+
     labs(x = NULL, y = "No. of confirmed cases",
          title = "COVID-19 cases in Andorra", subtitle = str_c("Source: Johns Hopkins CSSE (as of ", stamp_date("Oct 20 1979")(today()), ")"))+
     # this is a custom theme function, but theme_minimal() or your favourite theming function will do just as well!
     theme_wiki(md=T, base_size = 16, plot_margin = margin(20,80,50,50))
   
   ggsave(line_graph, filename = here("plots", "wiki_covid_andorra.png"), dev = "png", width = 16, height = 8)


Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

2 February 2021

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current07:55, 3 February 2021Thumbnail for version as of 07:55, 3 February 20214,800 × 2,400 (101 KB)GeneParmesan66Add title and source

The following page uses this file:

Metadata