0. The Basics of R: Practical 0
Introducing the gapminder data set
In this practical, we will work with the gapminder dataset. This dataset is stored in the gapminder package. The way to make it available in R is through this command:
library(gapminder)
If you get the following error:
Error in library(gapminder) : there is no package called ‘gapminder’
You can install the package through the command:
install.packages('gapminder')
After installing, you should then still load the package:
library(gapminder)
Help - I still get an Error!
If install.packages( )
fails (it sometimes happens if you have e.g. an old Mac OS), it is then best to copy-paste the following command in RStudio to load the data that you need for this practical:
source("http://horizon.science.uva.nl/public/VVA/gapminder.R")
If you have loaded the data in this way, you have the dataframe G available directly, and you can skip the first two commands below.
It is possible to take a brief look at the help file for the gapminder data, through the command:
?gapminder
In the lower-right pane of RStudio (the Help tab) an explanation about the contents of the gapminder package is given.
As you see, the gapminder dataset contains demographic and economic data per country (probably for most of the countries in the world).
It is now possible to load the data into a 'dataframe' in R and store it in an object, which we call G.
G <- data.frame(gapminder)
Note that you can see the object G appear in the upper-right pane of RStudio (in the Environment Tab). It tells that the dataframe G contains #1704# observations and #6# variables.