Welcome. In other video tutorials, I have already explained
how to identify an indicator that you are interested in, and download its data into
R. In this tutorial I will present how to draw a basic bar chart with this data. There are many user packages that can draw
basic charts in R. This time I will use the ggplot2 user package. Make sure that ggplot2 package installed in
your RStudio and it is included into your code. In one of my previous tutorials I showed how
to download one indicator’s data from the API. I will use those data. You can see the data here in the data frame
named data_from_api. I created it earlier, and it contains data
from the indicator with unique identifier HFA_74. If I take a look in my metadata I can see
that the code HFA_74 corresponds to “Infant deaths per 1000 live births”
I will make a copy of the data set and I will call it “barchart” data frame using the
following code and I will run it. If I browse my data frame I see that it contains
data for a set of years (1970-2015), for different sexes (all, females, males) and for country
groups. These country group values are population
weighed regional averages for a predefined group of countries. I would like to draw data for year 2013, with
total population values, and not showing any averages. So I have to filter my data for only the year
2013. I can perform this running the following code.
It should run very fast. Now I browse my data I can see that it contains
exactly the information I wanted. Once we have prepared our data we can draw
our bar chart. We can run this code. The bar chart is displayed in the right-bottom
window in the Plots tab. Here’s a nice bar chart that displays the
Infant deaths per 1000 live births among WHO/Europe countries. We can very easily see that the maximum infant
death rate is about 20 deaths per 1000 live births and the minimum is about 2 deaths per
1000 live births. Applying usual options of ggplot2 package
you can style the colour of bars, display labels on the bars. You can also sort the bars by sorting the
underlying dataset. For more information please see the ggplot2
package web site displayed on the right-bottom corner of the screen or you can search for
more documentation on internet. There is also the possibility to export your
graph as image or as pdf file. In similar ways, you can load the data from
the API, prepare it, and visualize it with your favourite package and graphs. This way you can script and always have the
latest data from WHO Europe available for your analysis.