🗓️ Sessions 12 and 13: Recap and practice
This session is about recap and practice. We will do exercises on topics that you suggest, and recap concepts you found particularly hard to grasp. To this end, make sure you communicate your preferences on topics via Moodle until one week before this session.
👨🏫 Lecture Slides
There were no slides used during this session.
🎥 Lecture videos
There will be no videos for recap sessions.
✍️ Exercises for the class
I suggest you create one R project environment for all the exercises of this session.
Solving the CO2 exercise from session 10 together
Download data about the CO2 emissions for some countries of your choice from the World Bank website for the years 2000 to 2020. Set up an R project, save the data, import it, and make a line graph.
Data wrangling I
Download and import the following data set on education spending and income.
Compute, for each country, the percentage change of the spending from the year 2010 to the year 2020 and save this as a variable called perc_change
.
Hint: The equation to compute the percentage change of a variable \(X\) from \(t=1\) to \(t=2\) is as follows:
\[g_X = \frac{X_{t=2}-X_{t=1}}{X_{t=1}}\cdot 100\]
Filter the data set such that there are no entries with a missing value in the variable perc_change
.
Save the new data set under a useful name in an adequate location.
Data wrangling II
Use the same data set as in the exercise before.
Compute for each income group the average expense of education over the whole period. Make sure missing values are ignored.
Save the new data set under a useful name in an adequate location.
Visualization and Quarto
Create a Quarto document and make sure that the following applies:
- Your name is set as the author of the file
- Your document is rendered to html format
- The title of the file is “Sessions 12 and 13: Recap and Practice”
- Sections are numbered
- There is a table of contents at the beginning of the document
Then read in the following data set on GDP per capita and child mortality.
Summarize the data per country such that you have one mean value for child mortality and GDP per capita for each country (ignoring missing values).
Create a scatter plot, in which the y axis shows child mortality and the x axis GDP per capita.
Then create a second scatter plot, in which both variables are transformed using the natural logarithm (using the R function log()
).
In your rendered quarto document, there should be no R code visible, only the output. Also, warnings and messages should not be visible.
📚 Suggested Reading
- Solutions to all the exercises
- Tutorial on using the WDI package (TBA)
- …