This page contains all the weekly exercises associated with the workbook. These exercises are designed to reinforce content taught each week. These exercises are split into basic and advance sections. It is expected that students can complete the basic sections of each weekly exercise, with the advanced sections designed for students who want an extra challenge or want learn additional R functions or statistical concepts not covered in the lecture series. Completing any of these exercises are not mandatory, but it is highly recommended.
Note: students enrolled in HPSP131 at the University of Stirling have access to an online version via the Canvas page.
Weekly exercises are contained in the zip file below. If the file does not download automatically when clicking the link, you may need to right-click the link and select the “Download” option.
Weekly Exercises
Download the file associated with the exercise you wish to complete. Save it on your computer and open this file in RStudio. This will open a RMarkdown Script.
In order to run the script, you will need the following packages (not all packages are needed for every week, but there is no harm in installing them all from the start). Run the following code in your RStudio console to download them; you will only need to run this code once:
install.packages(c("learnr","shiny","tidyverse","broom","lm.beta","psych","MASS","pwr","lme4","lmerTest"))
To open the exercise, click the ‘Run Document’ button in the toolbar above the script, as shown below. After a short wait, a separate window should open with the exercises for you to complete.
Depending on your operating system, this button may say ‘knit’ instead of ‘Run Document’. If this is the case, copy and paste the code below as the first lines of the script (like in the image above), then click the ‘knit’ button.
---
output: learnr::tutorial
runtime: shiny_prerendered
---
Typically, exercises consist of quiz questions and R exercises that require you to enter code into a box.
For the quiz questions, you will either need to select the correct answer, or select all true statements.
For questions that requires code, you will be presented with a box that acts like an RScript, such as below:
Usually, code boxes come with buttons along the top. The ‘Start Over’ button allows you to restart the question. If you are struggling to come up with an answer, you can click the ‘Hints’ button. Typically, there are two helpful hints, with the third “hint” being a possible solution. The ‘Run Code’ button will execute the code in the box, as if you were executing the code in the console.
The ‘Submit Answer’ button will run a check of your code; this check will identify common mistakes and return (sometimes) helpful feedback. If the code passes all checks, it will be returned as green. For more complicated code, or questions with more than one way to reach the solution, the check may return as green but still contain errors, so make sure you use your own judgement as well. If you believe your code is correct, but the check is still returning an error, please let your lecturer know via email: anthony.lee@stir.ac.uk.