Assignment 1
Preparation
Download this Rmarkdown file, fill in your name and student number, and complete your assignment in the Rmarkdown file. “knit” your text and code into a pdf-file, and upload this pdf-file on Brightspace before the next lecture.
Install and load new package
Install the gapminder
-package which allows you to make use of the gapminder dataset:
(you only have to do this once!)
Load the gapminder data:
Get a quick overview of the dataset
## # A tibble: 6 × 6
## country continent year lifeExp pop gdpPercap
## <fct> <fct> <int> <dbl> <int> <dbl>
## 1 Afghanistan Asia 1952 28.8 8425333 779.
## 2 Afghanistan Asia 1957 30.3 9240934 821.
## 3 Afghanistan Asia 1962 32.0 10267083 853.
## 4 Afghanistan Asia 1967 34.0 11537966 836.
## 5 Afghanistan Asia 1972 36.1 13079460 740.
## 6 Afghanistan Asia 1977 38.4 14880372 786.
For explanation of variables, click here.
Assignment
Create a histogram of
lifeExp
, the life-expectancy in years for the different countries in the dataset across the different years. Select an appropriate ‘binwidth’. Change colours to your liking.Describe in a few sentences what you see in the graph.
Create the same histogram, but only for the last year of measurement, which is 2007. You can create a new dataset for 2007 only by running the following code:
Explain in a few sentences how the graph is different from the one you created in 1.
For the dataset
gapminder_2007
, create density-plot for the variablepop
(referring to population size of a country). Choose colours to your liking.Also create a histogram. Add a different theme!
Why are both of the graphs not very informative?
Do you have a suggestion how to make this graph more informative?
Make a density-plot of the variable ‘countries’. Why doesn’t this work?
What would be a more appropriate type of graph for this variable?
Submit your pdf-file online
When you are done with your assignment, try clicking the “Knit”-button in Rstudio so that your code will be knitted into a pdf-file. Submit this file on Brightspace.
If you see an error appear, try to fix the error and try again. If you can’t get the “knitting” to work, then you can copy your code, text, and graphs into a word-file and submit it on Brightspace.