Note that since I write these codes for one of my current projects, not all of them are crucial in creating the plots.
- First, we need to load the following packages and define a function to compute differences and logarithmic differences (this is to compute the growth rates):
- Then, we extract the latest data from the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE)'s Github repository. There are three main variables of interest: The daily cumulative numbers of confirmed cases, recovered cases and death tolls:
- Next, we can do some reshaping the panel data from wide to long format:
- The next step is to compute the growth rates of these variables:
- I then create a nice theme for our ggplot2 plots:
- Now we can begin plotting. The first thing to do is to get the data for some representative countries. I include the big players that are featured heavily in the news and two developing ones (my home country and its neighbor, can you guess which one I am from?). You can modify this country list anyway you like:
- Then plot the daily cumulative epidemic curves using the confirmed cases and deaths. This result in the following plots:
- And finally, we can plot different varieties of these curves using the changes in cases and in death tolls: