<- readr::read_csv("data/tutorial_02_data.csv") mcq_data
Tutorial 02: Data Wrangling
Overview
This week is all about making changes to datasets. The phrase “data wrangling” covers all aspects of working with data, “wrangling” in the same way one might wrangle wild horses (well, metaphorically!). One of the main reasons you need this skill is to clean your dataset, which means to prepare it for analysis by dealing with mistakes or problematic values in the data, reformatting or recoding variables, and calculating new variables if necessary.
Today our key tasks will be:
- Practice the skill of reading codebooks and critically appraising the corresponding dataset, so that you can identify the differences between them that need wrangling.
- Revise the workhorse of data wrangling, the
dplyr::mutate()
function for making changes to variables in a dataset. - Learn a versatile new function,
dplyr::case_when()
, for conditionally creating values in a new variable.
Data
Task 1
Copy the code below into a new code chunk in your own Quarto document and run the code. You should see the new object, my_data
, appear in your Environment.
Then, call the name of the dataset to see what’s in it.
Codebook
A codebook (or “data dictionary” or similar) is a document that describes a dataset. It usually contains information about how each variable was collected, what the question(s) and response options were, and what kind of information the variable is meant to contain. It can take many forms - sometimes it might be your own plans or notes about the data you set out to collect!
However, things don’t always go according to plan. Before you do any work with a dataset, it’s always a good idea to compare the dataset to the codebook, looking out for any discrepancies or issues to resolve before you jump into the data analysis properly. Don’t just assume the data are perfect without checking for yourself.
Overview
This dataset is adapted from real data collected by Jenny Terry. The purpose is to investigate whether students score differently on a statistics MCQ exam when they’ve had either their standard teaching session or a gamified teaching session beforehand.
Exclusions
Once data collection is complete, preview runs should be removed, and check ethical requirements (consent, age).
Variables
Variable | Type | Description | Values |
---|---|---|---|
id | Categorical | Unique ID code | N/A |
test_round | Categorical | Time and year that the study was conducted | Spring 2024 |
distribution | Categorical | Channel through which the study was completed, either as a preview (before real data collection) or anonymous genuine responses. | "preview" or "anonymous" |
consent | Categorical | Whether the participant read the information sheet and consented to participate. | "Yes" or "No" |
gender | Categorical | Gender identity. | 1 = "female" 2 = "male" 3 = "non-binary" 4 = "other/pnts" Note: "pnts" is an abbreviation for "Prefer not to say". |
age | Numeric | Age in years. | Should be 18 - 99 |
mcq_score | Numeric | Total (summed) score on the MCQ questions. | 0 (all incorrect) to 50 (all correct) |
condition | Categorical | Whether participants saw the gamified statistics intervention or the standard intervention | "gamified" or "standard" |
mcq_perc | Numeric | MCQ score as a percentage correct out of 50 total questions. | 0% (all incorrect) to 100% (all correct) |
mcq_band | Categorical | Marking band that mcq_score falls in | 1st for scores above 70 2.1 for scores in the 60s 2.2 for scores in the 50s 3rd for scores in the 40s Fail for any scores below 40 |
To-Do List
Task 2
Inspect your dataset, and compare it to the Codebook above. Identify any discrepancies between the two, using the Codebook as a guide for what your dataset should look like, how it needs to be cleaned, and what variables it should contain.
Then, make a list below of the steps you must take to clean or change your dataset so that it matches the Codebook.
Note: For now, you can treat character data as categorical. (We’ll get into this more in second year!)
Now that we have a list of tasks to tackle, we need the tools to do it. That’s where our star this week comes in! You will likely have seen it before, but let’s do a little revision of the hardworking dplyr::mutate()
function.
Mutate
The mutate()
function is one of the most essential functions from the {dplyr} package. Its primary job is to easily and transparently make changes within a dataset - in particular, a tibble
.
Basic Form
To make a single, straightforward change to a tibble, use the basic form:
::mutate(
dplyr
dataset_name,variable_name = instructions_for_creating_the_variable
)
variable_name
is the name of the variable that will be changed by mutate()
. This can be any name that follows R’s object naming rules. There are two main options for this name:
- If the dataset does not already contain a variable called
variable_name
, a new variable will be added to the dataset. - If the dataset does already contain a variable called
variable_name
, the new variable will silently1 replace (i.e. overwrite) the existing variable with the same name.
instructions_for_creating_the_variable
tells the function how to create variable_name
. These instructions can be any valid R code, from a single value to complicated calculations or combinations of other variables. You can think of these instructions exactly the same way as the vector calculations we talked about last week.
Adding New Variables
As a first example to start working with mutate()
, imagine we have found some collaborators to work with on future rounds of this study, and we want to combine our datasets. To keep track of where the data came from, we want to add a lab
variable to our existing dataset, which should contain the name of the university before we add more data.
- 1
-
Make a change to the
mcq_data
dataset as follows: - 2
-
Create a new variable,
lab
, that contains the value"Sussex"
id | distribution | consent | gender | age | mcq_score | condition | lab |
---|---|---|---|---|---|---|---|
0C3da | anonymous | Yes | female | 20 | 27 | standard | Sussex |
0D7OT | anonymous | Yes | other/pnts | 20 | 18 | standard | Sussex |
0Sbvm | anonymous | NA | female | 19 | 14 | gamified | Sussex |
0c4cs | anonymous | Yes | female | 20 | 24 | gamified | Sussex |
0qtaJ | anonymous | Yes | female | 19 | 8 | gamified | Sussex |
0upnc | anonymous | Yes | female | 19 | 27 | standard | Sussex |
11RWE | anonymous | Yes | other/pnts | 18 | 16 | gamified | Sussex |
13ECk | anonymous | Yes | female | 18 | 16 | gamified | Sussex |
14hab | anonymous | Yes | female | 19 | 36 | gamified | Sussex |
17DVa | anonymous | Yes | other/pnts | 19 | 35 | gamified | Sussex |
1Rn6s | anonymous | Yes | male | 18 | 32 | gamified | Sussex |
1U3uo | preview | Yes | female | 19 | 24 | gamified | Sussex |
1VTIt | anonymous | Yes | male | 17 | 32 | standard | Sussex |
1YdZV | anonymous | Yes | female | 19 | 16 | standard | Sussex |
1Zycx | anonymous | Yes | other/pnts | 21 | 24 | standard | Sussex |
1crQC | anonymous | Yes | female | 19 | 36 | gamified | Sussex |
25pc7 | anonymous | Yes | female | 19 | 16 | gamified | Sussex |
2JwwB | anonymous | Yes | female | 20 | 40 | standard | Sussex |
2Nrw1 | anonymous | Yes | female | 18 | 28 | gamified | Sussex |
2Rauy | anonymous | Yes | female | 21 | NA | standard | Sussex |
2eaqo | anonymous | Yes | female | 19 | 28 | gamified | Sussex |
2jBId | anonymous | No | female | 18 | 14 | standard | Sussex |
2jceE | anonymous | Yes | female | 18 | 24 | standard | Sussex |
2nPXu | anonymous | Yes | male | 19 | NA | gamified | Sussex |
2u1pE | anonymous | Yes | female | 19 | 36 | gamified | Sussex |
30f1u | anonymous | Yes | female | 18 | 27 | standard | Sussex |
3U4eV | anonymous | Yes | female | 19 | NA | standard | Sussex |
3UxFq | anonymous | Yes | female | 19 | 36 | gamified | Sussex |
3co3p | anonymous | Yes | non-binary | 19 | 27 | gamified | Sussex |
3fsST | anonymous | Yes | female | 60 | 24 | gamified | Sussex |
3i2E1 | anonymous | Yes | female | 19 | 32 | standard | Sussex |
3tYkD | anonymous | Yes | female | 230 | 10 | standard | Sussex |
42gb3 | anonymous | Yes | other/pnts | 20 | 40 | standard | Sussex |
4AOOf | anonymous | Yes | female | 20 | 36 | standard | Sussex |
4DdZ7 | anonymous | Yes | female | 20 | 14 | standard | Sussex |
4bD0z | anonymous | NA | other/pnts | 18 | 32 | gamified | Sussex |
4fj5T | anonymous | Yes | male | 180 | 28 | standard | Sussex |
4sl1v | anonymous | Yes | male | 17 | 8 | gamified | Sussex |
567FX | anonymous | Yes | male | 20 | 16 | standard | Sussex |
57VIy | anonymous | Yes | female | 20 | NA | gamified | Sussex |
5P1SM | anonymous | Yes | female | 21 | 9 | standard | Sussex |
5R6kh | anonymous | Yes | female | 19 | 24 | standard | Sussex |
5kwV6 | anonymous | Yes | female | 21 | 14 | standard | Sussex |
604sE | anonymous | Yes | female | 17 | 24 | standard | Sussex |
60RT2 | anonymous | Yes | female | 18 | 28 | standard | Sussex |
6BURB | anonymous | No | other/pnts | 21 | 18 | standard | Sussex |
6eXcl | anonymous | Yes | female | 20 | 16 | standard | Sussex |
6ieyf | anonymous | Yes | female | 20 | 16 | gamified | Sussex |
79bUy | anonymous | Yes | female | 37 | 14 | standard | Sussex |
7IBO5 | anonymous | Yes | female | 20 | 18 | gamified | Sussex |
7Rnrs | anonymous | Yes | female | 20 | NA | gamified | Sussex |
7aqLl | anonymous | Yes | other/pnts | 17 | 16 | standard | Sussex |
7cNhh | anonymous | Yes | female | 19 | 16 | gamified | Sussex |
7nmrS | anonymous | Yes | male | 20 | 24 | gamified | Sussex |
7q2mO | anonymous | Yes | female | 20 | 28 | gamified | Sussex |
7q31O | anonymous | NA | female | 19 | NA | standard | Sussex |
7suHW | anonymous | Yes | female | 17 | 14 | gamified | Sussex |
8FULZ | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
8NDBN | anonymous | Yes | female | 20 | NA | standard | Sussex |
8QRNK | anonymous | Yes | non-binary | 18 | 24 | standard | Sussex |
8VtOH | anonymous | Yes | female | 21 | 36 | gamified | Sussex |
8a4cQ | anonymous | Yes | female | 18 | 16 | standard | Sussex |
8gZ4N | anonymous | Yes | male | 20 | 32 | gamified | Sussex |
8njXv | preview | NA | female | 18 years | 36 | standard | Sussex |
8oJjk | anonymous | Yes | female | 18 | 27 | gamified | Sussex |
91elw | anonymous | Yes | male | 19 | 40 | gamified | Sussex |
9C8jB | anonymous | Yes | other/pnts | 19 | 28 | standard | Sussex |
9JizO | anonymous | Yes | male | 20 | 36 | standard | Sussex |
9eSGk | anonymous | Yes | female | 20 | 16 | gamified | Sussex |
9kScn | anonymous | Yes | female | 20 | 50 | gamified | Sussex |
9mpUu | anonymous | Yes | other/pnts | 52 | 14 | standard | Sussex |
9vOj2 | anonymous | Yes | other/pnts | 20 | NA | gamified | Sussex |
A0bdM | anonymous | Yes | female | 20 | 14 | gamified | Sussex |
A3fBz | anonymous | Yes | other/pnts | 26 | 18 | standard | Sussex |
AB3Ij | anonymous | Yes | female | 19 | 27 | gamified | Sussex |
ABIG8 | anonymous | Yes | female | 18 | 24 | standard | Sussex |
AIDGD | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
AMVGF | anonymous | Yes | other/pnts | 20 | 27 | gamified | Sussex |
AU8Xf | anonymous | Yes | female | 19 | 24 | standard | Sussex |
B3sQT | anonymous | Yes | male | 20 years old | 21 | gamified | Sussex |
B9ptw | anonymous | Yes | female | 18 | 24 | standard | Sussex |
BD5VH | anonymous | Yes | female | 17 | 35 | standard | Sussex |
BKRNd | anonymous | Yes | female | 19 | 22 | standard | Sussex |
BLQ0T | anonymous | Yes | other/pnts | 19 | 12 | gamified | Sussex |
BMp5i | anonymous | Yes | female | 18 | 45 | standard | Sussex |
BOAq9 | anonymous | Yes | other/pnts | 20 | 21 | standard | Sussex |
BQzv9 | anonymous | Yes | female | 20 | 18 | gamified | Sussex |
BT3yn | anonymous | Yes | other/pnts | 17 | NA | gamified | Sussex |
BaEJT | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
Bawej | anonymous | Yes | male | 18 | 27 | gamified | Sussex |
BwZMT | anonymous | Yes | female | 19 | NA | gamified | Sussex |
BxoYr | anonymous | Yes | male | 19 | 21 | gamified | Sussex |
C0uUo | anonymous | Yes | female | 20 | 16 | standard | Sussex |
C2yd8 | anonymous | Yes | female | 19 | NA | gamified | Sussex |
C7cZS | anonymous | Yes | other/pnts | 20 | 35 | gamified | Sussex |
CNnTV | anonymous | NA | female | 210 | 7 | gamified | Sussex |
CWz9G | anonymous | Yes | female | 22 | 36 | gamified | Sussex |
CXCEY | anonymous | Yes | female | 19 | NA | standard | Sussex |
CZAvP | anonymous | Yes | female | 20 | NA | gamified | Sussex |
CZkx0 | anonymous | Yes | female | 20 | 14 | standard | Sussex |
CkUqi | anonymous | Yes | female | 19 | 27 | standard | Sussex |
Cntlm | anonymous | Yes | female | 18 | 24 | standard | Sussex |
D09VK | preview | Yes | female | 20 | NA | gamified | Sussex |
D27tu | anonymous | Yes | female | 20 | 24 | standard | Sussex |
D4Ouu | anonymous | Yes | female | 32 | NA | gamified | Sussex |
D8xUm | anonymous | Yes | female | 20 | 21 | gamified | Sussex |
DKWAC | anonymous | Yes | male | 18 | NA | standard | Sussex |
DNVaD | anonymous | Yes | female | 19 | NA | standard | Sussex |
DQMDF | anonymous | Yes | female | 19 | 40 | standard | Sussex |
DR76B | anonymous | Yes | female | 20 | 24 | gamified | Sussex |
DSXgx | anonymous | Yes | female | 21 | 35 | gamified | Sussex |
DcHno | anonymous | Yes | female | 20 | NA | standard | Sussex |
DoFNW | anonymous | Yes | other/pnts | 18 | 16 | gamified | Sussex |
DoH5g | anonymous | No | female | 19 | NA | standard | Sussex |
DxQWx | anonymous | Yes | female | 20 | 6 | gamified | Sussex |
EBecP | anonymous | Yes | female | 19 | NA | standard | Sussex |
EGFk2 | anonymous | Yes | female | 18 | 9 | gamified | Sussex |
ELGp5 | anonymous | Yes | male | 18 | NA | gamified | Sussex |
EPLlm | anonymous | Yes | female | 19 | 36 | gamified | Sussex |
EjbZG | anonymous | No | male | 19 | 40 | gamified | Sussex |
EjpDL | anonymous | Yes | female | 18 | 27 | gamified | Sussex |
Er8lG | anonymous | Yes | female | 18 | 32 | gamified | Sussex |
F6UhY | anonymous | Yes | female | 18 | 8 | standard | Sussex |
FEPUM | anonymous | Yes | female | 19 | 35 | standard | Sussex |
FHqks | anonymous | Yes | female | 19 | 36 | standard | Sussex |
FLUxb | anonymous | Yes | female | 18 | 32 | gamified | Sussex |
FQ9jA | anonymous | Yes | female | 19 | 27 | standard | Sussex |
FXs3X | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
FY4Qd | anonymous | Yes | female | 19 | 24 | standard | Sussex |
FgC2w | anonymous | Yes | other/pnts | 20 | 16 | standard | Sussex |
Fv6Hm | anonymous | Yes | female | 19 | 14 | standard | Sussex |
FxA3a | anonymous | Yes | other/pnts | 20 | 0 | standard | Sussex |
G750q | anonymous | Yes | female | 18 | 28 | gamified | Sussex |
GF7AW | anonymous | Yes | female | 18 | 40 | gamified | Sussex |
GIdfy | anonymous | Yes | other/pnts | 20 | 24 | standard | Sussex |
GPeCC | anonymous | Yes | female | 20 | 24 | standard | Sussex |
GXFHo | anonymous | Yes | female | 18 | 36 | standard | Sussex |
GtuVx | anonymous | Yes | female | 18 | 21 | standard | Sussex |
GwzPE | preview | Yes | non-binary | 19 | 12 | gamified | Sussex |
H0grb | anonymous | Yes | female | 19 | 40 | gamified | Sussex |
Htlec | anonymous | Yes | male | 190 | 24 | gamified | Sussex |
IB3jV | anonymous | Yes | other/pnts | 19 | NA | standard | Sussex |
IJpxI | anonymous | Yes | male | 20 | 8 | standard | Sussex |
IaQTG | anonymous | Yes | female | 19 | 36 | gamified | Sussex |
ItPc5 | anonymous | Yes | other/pnts | 19 | 28 | standard | Sussex |
IxAfx | anonymous | Yes | female | 19 | 24 | standard | Sussex |
IxCJg | anonymous | Yes | other/pnts | 19 | 14 | standard | Sussex |
IybPq | anonymous | Yes | female | 19 | 27 | standard | Sussex |
J5rW4 | anonymous | Yes | female | 20 | 16 | gamified | Sussex |
Jb4Zj | anonymous | Yes | other/pnts | 18 | NA | gamified | Sussex |
Jfu4H | anonymous | NA | male | 18 | NA | gamified | Sussex |
JmGnA | anonymous | Yes | female | 19 | 45 | standard | Sussex |
K4ccy | anonymous | Yes | female | 19 | 40 | standard | Sussex |
K4cqA | anonymous | Yes | female | 20 | 16 | gamified | Sussex |
K5AI8 | anonymous | Yes | female | 20 | 30 | gamified | Sussex |
K6WAN | anonymous | Yes | female | 21 | 30 | standard | Sussex |
KH29p | anonymous | Yes | female | 19 | 0 | gamified | Sussex |
KJnFK | anonymous | Yes | female | 18 | 40 | gamified | Sussex |
KQSrs | preview | NA | male | 21 | 16 | standard | Sussex |
KaPny | anonymous | Yes | male | 19 | 18 | standard | Sussex |
KarR9 | anonymous | Yes | female | 19 | NA | standard | Sussex |
KcUpk | anonymous | Yes | female | 18 | 12 | gamified | Sussex |
Kf7xs | anonymous | Yes | female | 18 | 16 | standard | Sussex |
KjaQK | anonymous | Yes | female | 18 | 32 | gamified | Sussex |
L0CPk | anonymous | Yes | other/pnts | 18 | 20 | standard | Sussex |
L4Qxw | anonymous | Yes | male | 19 | 28 | gamified | Sussex |
LONaU | anonymous | Yes | female | 18 | NA | gamified | Sussex |
LYiMm | anonymous | Yes | other/pnts | 20 | NA | gamified | Sussex |
LZPJq | anonymous | Yes | female | 19 | 32 | standard | Sussex |
Ljcpu | anonymous | Yes | other/pnts | 24 | 28 | standard | Sussex |
LlCNK | anonymous | Yes | female | 18 | NA | gamified | Sussex |
M2MI0 | anonymous | Yes | other/pnts | 19 | 27 | standard | Sussex |
M4BLy | anonymous | Yes | female | 18 | NA | standard | Sussex |
M8Oxv | anonymous | Yes | female | 19 | 9 | standard | Sussex |
MBn1k | anonymous | Yes | female | 21 | 27 | gamified | Sussex |
MFJt5 | anonymous | Yes | male | 21 | 0 | standard | Sussex |
MIov5 | anonymous | Yes | other/pnts | 20 | NA | gamified | Sussex |
MZjPB | anonymous | NA | non-binary | 19 | 27 | gamified | Sussex |
MhO9r | anonymous | Yes | male | 19 | 21 | gamified | Sussex |
MuIEO | anonymous | Yes | male | 22 | NA | standard | Sussex |
N0jIl | anonymous | Yes | female | 17 | 16 | gamified | Sussex |
N6FTh | anonymous | Yes | female | 19 | 21 | standard | Sussex |
NdYHw | anonymous | Yes | male | 17 | NA | standard | Sussex |
NqFOx | anonymous | Yes | male | 19 | 27 | standard | Sussex |
O5JsZ | anonymous | Yes | male | 19 | 20 | standard | Sussex |
O8CdZ | anonymous | Yes | female | 19 | 32 | standard | Sussex |
OGIx2 | anonymous | Yes | female | 22 | 27 | standard | Sussex |
OXSGm | anonymous | Yes | female | 20 | 32 | standard | Sussex |
Ovi8C | anonymous | Yes | female | 20 | 12 | gamified | Sussex |
OygRR | anonymous | Yes | female | 19 | 18 | standard | Sussex |
PHYsH | anonymous | Yes | female | 19 | 28 | standard | Sussex |
PWZd9 | anonymous | Yes | female | 19 | 40 | standard | Sussex |
QDq3A | anonymous | Yes | female | 49 | 36 | gamified | Sussex |
QDtKQ | anonymous | Yes | female | 18 | NA | gamified | Sussex |
QQVJe | anonymous | Yes | female | 18 | NA | gamified | Sussex |
Qcugp | anonymous | Yes | female | 34 | 35 | gamified | Sussex |
QpLrh | anonymous | Yes | female | 19 | 14 | gamified | Sussex |
R2B6T | anonymous | Yes | non-binary | 20 | 27 | standard | Sussex |
R2Y7E | anonymous | Yes | female | 220 | 45 | gamified | Sussex |
R47v6 | anonymous | Yes | other/pnts | 18 | 27 | gamified | Sussex |
RCDNX | anonymous | Yes | female | 18 | 28 | standard | Sussex |
RFJnJ | anonymous | Yes | female | 19 | 9 | standard | Sussex |
RKrjC | anonymous | Yes | female | 21 | 36 | gamified | Sussex |
RVUhK | anonymous | Yes | female | 19 | 35 | gamified | Sussex |
RhYFX | anonymous | Yes | other/pnts | 20 | 18 | gamified | Sussex |
RxCMC | anonymous | Yes | female | 18 | 8 | gamified | Sussex |
SAkjm | anonymous | Yes | male | 20 | 21 | standard | Sussex |
SZWB3 | anonymous | Yes | female | 18 | 45 | gamified | Sussex |
SaC0c | anonymous | Yes | female | 19 | 16 | standard | Sussex |
TAtlY | anonymous | Yes | female | 19 | NA | standard | Sussex |
Td2sp | anonymous | Yes | other/pnts | 43 | 24 | gamified | Sussex |
Tvu4K | anonymous | Yes | other/pnts | 47 | 24 | standard | Sussex |
U7rUC | anonymous | Yes | female | 20 | 0 | standard | Sussex |
UJPCB | preview | Yes | female | 18 | 28 | standard | Sussex |
UUvvR | anonymous | Yes | female | 18 | 32 | gamified | Sussex |
UfHKg | preview | Yes | other/pnts | 18 | 36 | standard | Sussex |
UoCiQ | anonymous | Yes | female | 44 | NA | standard | Sussex |
UsFJA | anonymous | Yes | other/pnts | 21 | NA | standard | Sussex |
VAsax | anonymous | Yes | male | 19 | 32 | gamified | Sussex |
VAzZ4 | preview | Yes | female | 19 | 18 | gamified | Sussex |
VEsAZ | anonymous | Yes | female | 20 | NA | standard | Sussex |
VFHCz | anonymous | Yes | female | 18 | NA | standard | Sussex |
VLNR8 | anonymous | Yes | female | 19 | 18 | standard | Sussex |
VSXkO | anonymous | Yes | female | 19 | 32 | gamified | Sussex |
VX0eQ | anonymous | Yes | female | 19 | 14 | gamified | Sussex |
VZ8g2 | anonymous | Yes | other/pnts | 20 | NA | gamified | Sussex |
Vauqd | anonymous | Yes | female | 18 | 18 | gamified | Sussex |
Vgbl2 | anonymous | Yes | female | 19 | 27 | standard | Sussex |
VpL9v | anonymous | No | female | 19 | 27 | gamified | Sussex |
VrH7Z | anonymous | Yes | female | 19 | 16 | gamified | Sussex |
Vu8ja | anonymous | Yes | female | 20 | 27 | gamified | Sussex |
W0GJa | anonymous | Yes | female | 20 | 27 | standard | Sussex |
WBwEl | anonymous | Yes | female | 18 | NA | standard | Sussex |
WFtTV | anonymous | Yes | female | 21 | 18 | gamified | Sussex |
WIBkj | anonymous | Yes | male | 18 | 32 | gamified | Sussex |
WRhXk | anonymous | NA | female | 19 | 24 | standard | Sussex |
WZeXp | anonymous | Yes | female | 19 | 18 | gamified | Sussex |
Wa4i1 | anonymous | Yes | male | 20 | NA | gamified | Sussex |
WdOtI | anonymous | Yes | male | 18 | NA | standard | Sussex |
WhMr1 | anonymous | Yes | female | 19 | 16 | standard | Sussex |
WkVff | anonymous | Yes | male | 20 | 14 | standard | Sussex |
Wkczy | anonymous | Yes | male | 42 | 16 | standard | Sussex |
WpZoF | anonymous | Yes | female | 20 | 18 | standard | Sussex |
WrbdV | anonymous | Yes | female | 20 | 7 | standard | Sussex |
WvTTm | anonymous | Yes | female | 19 | 32 | gamified | Sussex |
Wxab9 | anonymous | Yes | female | 46 | 14 | standard | Sussex |
WzwfL | anonymous | Yes | female | 19 | 16 | standard | Sussex |
X4X9u | anonymous | Yes | female | 19 | 8 | gamified | Sussex |
X94fv | anonymous | Yes | female | 21 | NA | standard | Sussex |
XMUsl | anonymous | Yes | male | 20 | 24 | standard | Sussex |
XNla5 | anonymous | Yes | female | 19 | 32 | gamified | Sussex |
XRmHi | anonymous | Yes | female | 19 | 40 | gamified | Sussex |
XTNNv | anonymous | Yes | female | 19 | 24 | standard | Sussex |
XdQAZ | anonymous | Yes | other/pnts | 21 | 21 | gamified | Sussex |
XdULZ | anonymous | Yes | other/pnts | 18 | 6 | gamified | Sussex |
Xhe8o | anonymous | Yes | female | 19 | 24 | standard | Sussex |
Y4hX5 | anonymous | Yes | other/pnts | 17 | 30 | gamified | Sussex |
Y9l70 | anonymous | Yes | female | 19 | 45 | gamified | Sussex |
YBBpv | anonymous | Yes | male | 20 | 10 | standard | Sussex |
YDlvy | anonymous | Yes | female | 39 | 28 | standard | Sussex |
YI5OX | preview | Yes | male | 23 | 28 | gamified | Sussex |
YJiyx | anonymous | Yes | male | 18 | 18 | gamified | Sussex |
YyvSr | anonymous | Yes | female | 20 | 16 | gamified | Sussex |
Z3D1i | anonymous | Yes | female | 18 | 30 | standard | Sussex |
Z5pG4 | anonymous | Yes | female | 20 | 35 | standard | Sussex |
ZdlsP | anonymous | Yes | female | 17 | 30 | standard | Sussex |
ZfbJ5 | anonymous | No | other/pnts | 19 | 32 | gamified | Sussex |
Zikvz | anonymous | Yes | female | 20 | 24 | gamified | Sussex |
ZmXSs | anonymous | Yes | female | 18 | 21 | standard | Sussex |
aLaPg | anonymous | Yes | male | 18 | 40 | gamified | Sussex |
adPdh | anonymous | Yes | female | 19 | NA | standard | Sussex |
aeqF8 | anonymous | Yes | female | 20 | 30 | gamified | Sussex |
ajiJb | anonymous | NA | female | 20 | NA | gamified | Sussex |
an4Bk | anonymous | Yes | male | 18 | 18 | standard | Sussex |
asHWN | anonymous | Yes | female | 20 | 35 | gamified | Sussex |
bWJ9P | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
bbEVT | anonymous | Yes | other/pnts | 20 | 9 | gamified | Sussex |
bq9vF | anonymous | Yes | other/pnts | 19 | 16 | standard | Sussex |
cF65b | anonymous | Yes | female | 20 | 32 | standard | Sussex |
cLK5b | anonymous | Yes | female | 17 | 40 | gamified | Sussex |
caofW | anonymous | Yes | female | 20 | 18 | standard | Sussex |
cwMSQ | anonymous | Yes | female | 19 | 18 | standard | Sussex |
d4rJu | anonymous | Yes | other/pnts | 57 | 21 | gamified | Sussex |
dGttD | anonymous | Yes | male | 21 | 24 | standard | Sussex |
dSPKO | anonymous | Yes | female | 20 | 40 | gamified | Sussex |
daDjs | anonymous | Yes | female | 19 | 27 | standard | Sussex |
dl5cO | anonymous | Yes | female | 51 | 7 | standard | Sussex |
dtOna | anonymous | Yes | male | 20 | NA | gamified | Sussex |
eFBcM | anonymous | NA | female | 19 | 8 | standard | Sussex |
eGI1r | anonymous | Yes | other/pnts | 20 | 14 | gamified | Sussex |
eXXqe | anonymous | Yes | female | 20 | 18 | gamified | Sussex |
fCUzB | anonymous | Yes | female | 19 | 16 | standard | Sussex |
fIkUH | anonymous | Yes | male | 18 | 45 | gamified | Sussex |
fL8q6 | anonymous | No | female | 19 | 40 | gamified | Sussex |
fMpxN | anonymous | Yes | female | 20 | 16 | standard | Sussex |
fXyk6 | anonymous | Yes | female | 19 | NA | standard | Sussex |
faZaK | anonymous | Yes | female | 18 | 16 | standard | Sussex |
fevx8 | anonymous | Yes | female | 19 | NA | standard | Sussex |
fvTHz | anonymous | Yes | female | 19 | 16 | standard | Sussex |
fyRug | anonymous | Yes | other/pnts | 20 | 18 | standard | Sussex |
fysPC | anonymous | Yes | female | 20 | 9 | gamified | Sussex |
gEk8c | anonymous | Yes | female | 20 | 45 | gamified | Sussex |
gFk3j | anonymous | Yes | female | 19 | NA | gamified | Sussex |
gLGEb | anonymous | Yes | female | 20 | 32 | standard | Sussex |
gTwyG | anonymous | Yes | other/pnts | 19 | NA | gamified | Sussex |
gbS51 | anonymous | Yes | female | 20 | 8 | standard | Sussex |
getql | anonymous | Yes | female | 20 | 36 | standard | Sussex |
gys2m | anonymous | Yes | female | 19 | 0 | gamified | Sussex |
h9bgT | anonymous | Yes | female | 21 | 36 | gamified | Sussex |
hAk7r | anonymous | Yes | female | 19 | 27 | standard | Sussex |
hL89D | anonymous | Yes | other/pnts | 18 | 28 | gamified | Sussex |
hO1d9 | anonymous | Yes | female | 18 | 8 | gamified | Sussex |
hVnBV | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
hvnBr | anonymous | No | female | 20 | NA | gamified | Sussex |
hwSwZ | anonymous | Yes | female | 19 | 33 | standard | Sussex |
i59RR | anonymous | NA | other/pnts | 20 | 36 | gamified | Sussex |
iCrQN | anonymous | Yes | female | 19 | 36 | standard | Sussex |
iD9hw | anonymous | Yes | female | 19 | NA | standard | Sussex |
iPxF0 | anonymous | Yes | female | 19 | 20 | gamified | Sussex |
iXfgl | anonymous | Yes | female | 18 | 6 | standard | Sussex |
iZ5Ke | anonymous | Yes | other/pnts | 54 | 21 | standard | Sussex |
il39l | anonymous | Yes | female | 19 | NA | standard | Sussex |
j7KVe | anonymous | Yes | female | 20 | 18 | gamified | Sussex |
jHGu5 | anonymous | Yes | female | 45 | 36 | gamified | Sussex |
jLARq | anonymous | Yes | other/pnts | 19 | 24 | standard | Sussex |
jSyAN | anonymous | Yes | other/pnts | 17 | 27 | standard | Sussex |
jWq9O | anonymous | Yes | female | 18 | 27 | gamified | Sussex |
jf3nH | anonymous | Yes | female | 20 | 18 | standard | Sussex |
jgRNK | anonymous | Yes | female | 19 | 21 | standard | Sussex |
ji41d | anonymous | Yes | female | 16 | 18 | standard | Sussex |
jmLsY | anonymous | Yes | female | 18 | 18 | gamified | Sussex |
jmwSi | anonymous | Yes | female | 18 | 36 | gamified | Sussex |
jrDKg | anonymous | Yes | female | 20 | NA | gamified | Sussex |
jtMtP | anonymous | Yes | female | 18 | 6 | gamified | Sussex |
k6UDx | anonymous | Yes | male | 19 | 8 | standard | Sussex |
kEP1V | anonymous | Yes | non-binary | 53 | NA | gamified | Sussex |
kMNiI | anonymous | Yes | female | 20 | NA | standard | Sussex |
kPaPZ | anonymous | Yes | female | 19 | 21 | gamified | Sussex |
kRMUF | anonymous | Yes | female | 19 | 7 | standard | Sussex |
kS1iR | anonymous | Yes | female | 18 | 9 | standard | Sussex |
kYoLp | anonymous | Yes | female | 21 | 16 | standard | Sussex |
kcnVj | anonymous | Yes | female | 19 | 24 | standard | Sussex |
khOxC | anonymous | Yes | female | 19 | 27 | standard | Sussex |
kl0sP | anonymous | Yes | female | 18 | 40 | gamified | Sussex |
kmG6j | anonymous | Yes | female | 19 | 20 | standard | Sussex |
kytPK | anonymous | Yes | other/pnts | 19 | 27 | standard | Sussex |
l60b2 | anonymous | Yes | female | 20 | 24 | standard | Sussex |
lGp5b | anonymous | Yes | female | 17 | 9 | standard | Sussex |
lWSMK | anonymous | NA | female | 19 | 16 | gamified | Sussex |
lZYPj | anonymous | Yes | male | 19 | NA | standard | Sussex |
leQj6 | anonymous | No | female | 20 | 8 | standard | Sussex |
llurT | anonymous | Yes | female | 18 | 21 | standard | Sussex |
loO7K | anonymous | Yes | female | 21 | 36 | gamified | Sussex |
lvGzW | anonymous | Yes | female | 19 | 28 | standard | Sussex |
lyC9q | anonymous | Yes | male | 18 | 36 | standard | Sussex |
m2Dcx | anonymous | Yes | female | 17 | 32 | gamified | Sussex |
m5atb | anonymous | No | other/pnts | 18 | 45 | gamified | Sussex |
m7RM9 | anonymous | NA | male | 20 | 24 | standard | Sussex |
mNfOf | anonymous | Yes | female | 20 | 24 | gamified | Sussex |
mRJfz | anonymous | Yes | female | 18 | 32 | gamified | Sussex |
mUe2L | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
mVFza | anonymous | Yes | other/pnts | 19 | 16 | standard | Sussex |
mWF7h | anonymous | Yes | other/pnts | 18 | NA | standard | Sussex |
mfTib | anonymous | Yes | female | 20 | 18 | standard | Sussex |
mgU6J | anonymous | Yes | female | 18 | 24 | gamified | Sussex |
mm5mY | anonymous | Yes | male | 20 | NA | gamified | Sussex |
mw4Kf | anonymous | Yes | female | 19 | 18 | standard | Sussex |
n33R4 | anonymous | Yes | female | 27 | 36 | standard | Sussex |
n4R4P | anonymous | Yes | female | 19 | 16 | gamified | Sussex |
n5DlS | anonymous | NA | female | 19 | NA | gamified | Sussex |
nQtEb | anonymous | Yes | female | 19 | NA | standard | Sussex |
nRG2C | preview | NA | female | 20 | 40 | gamified | Sussex |
nSNLc | anonymous | Yes | female | 17 | NA | standard | Sussex |
njgt8 | anonymous | Yes | female | 20 | 21 | gamified | Sussex |
nm9bk | anonymous | Yes | female | 17 | NA | gamified | Sussex |
no5PW | anonymous | Yes | female | 19 | NA | gamified | Sussex |
noVdw | anonymous | Yes | female | 48 | 45 | gamified | Sussex |
nyaYZ | anonymous | Yes | female | 20 | 40 | gamified | Sussex |
o0nLV | preview | Yes | female | 19 | 21 | standard | Sussex |
oGu48 | anonymous | Yes | other/pnts | 18 | 28 | standard | Sussex |
oRz5N | anonymous | Yes | female | 18 | 32 | standard | Sussex |
oTapN | anonymous | Yes | male | 18 | 27 | standard | Sussex |
oYLJv | anonymous | No | female | 19 | 20 | standard | Sussex |
ocAbh | anonymous | NA | male | 18 | 12 | standard | Sussex |
ouFFF | anonymous | Yes | female | 19 | NA | gamified | Sussex |
p4ZE3 | anonymous | Yes | female | 200 | 18 | standard | Sussex |
pQZlb | anonymous | Yes | male | 18 | NA | standard | Sussex |
pXcHr | anonymous | Yes | female | 21 | 18 | standard | Sussex |
pnZuQ | anonymous | Yes | female | 19 | NA | gamified | Sussex |
qHA0y | anonymous | NA | female | 18 | 40 | gamified | Sussex |
qIdkI | anonymous | Yes | other/pnts | 18 | 32 | standard | Sussex |
qN6C4 | anonymous | Yes | female | 18 | 24 | gamified | Sussex |
qN9TW | anonymous | NA | female | 21 | 24 | gamified | Sussex |
qQwMw | preview | Yes | female | 20 | 14 | gamified | Sussex |
qXrrA | anonymous | Yes | male | 20 | 30 | gamified | Sussex |
qYYts | anonymous | Yes | female | 21 | NA | gamified | Sussex |
qb9LW | anonymous | Yes | other/pnts | 19 | NA | gamified | Sussex |
qejj5 | anonymous | Yes | female | 19 | NA | standard | Sussex |
qhsfF | anonymous | Yes | female | 18 | 40 | gamified | Sussex |
qkyKI | anonymous | Yes | female | 17 | 24 | gamified | Sussex |
qtaGK | anonymous | Yes | other/pnts | 19 | 32 | standard | Sussex |
r50GM | anonymous | Yes | female | 19 | NA | gamified | Sussex |
rDPQX | anonymous | Yes | female | 20 | 32 | gamified | Sussex |
rFHo4 | anonymous | NA | female | 20 | 50 | gamified | Sussex |
rOXvR | anonymous | No | female | 19 | 18 | gamified | Sussex |
rcnu3 | anonymous | Yes | other/pnts | 20 | 16 | gamified | Sussex |
rhVte | anonymous | Yes | other/pnts | 20 | 36 | gamified | Sussex |
rriRG | anonymous | Yes | female | 19 | 21 | gamified | Sussex |
s4P5c | anonymous | NA | female | 17 | 28 | gamified | Sussex |
s94aP | anonymous | Yes | female | 19 | 16 | gamified | Sussex |
sMnDB | anonymous | Yes | female | 21 | 24 | standard | Sussex |
sXQ1a | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
seB6W | anonymous | Yes | male | 20 | 18 | standard | Sussex |
smrQ6 | anonymous | Yes | other/pnts | 21 | 28 | gamified | Sussex |
swu32 | anonymous | Yes | female | 20 | NA | standard | Sussex |
sxLaB | anonymous | Yes | female | 21 | NA | gamified | Sussex |
t1mfp | anonymous | Yes | female | 55 | 27 | standard | Sussex |
t78FX | anonymous | Yes | female | 19 | 45 | standard | Sussex |
tNLJ3 | anonymous | Yes | female | 20 | NA | standard | Sussex |
tNuov | anonymous | Yes | female | 20 | 21 | standard | Sussex |
tP3EH | anonymous | Yes | male | 19 | 27 | gamified | Sussex |
tPgph | anonymous | Yes | female | 20 | NA | standard | Sussex |
tRubH | anonymous | Yes | non-binary | 21 | NA | standard | Sussex |
td473 | anonymous | No | male | 18 | 12 | standard | Sussex |
tiMsW | anonymous | Yes | female | 20 | 9 | standard | Sussex |
u4hGl | anonymous | Yes | female | 36 | 27 | gamified | Sussex |
uEu4N | anonymous | Yes | female | 18 | NA | gamified | Sussex |
uQ6Yl | anonymous | Yes | female | 19 | 16 | gamified | Sussex |
uaJGu | anonymous | Yes | male | 20 | 16 | gamified | Sussex |
ubxCE | anonymous | Yes | other/pnts | 18 | 24 | gamified | Sussex |
ucGBA | anonymous | Yes | female | 19 | 9 | standard | Sussex |
udr3I | anonymous | Yes | other/pnts | 18 | NA | gamified | Sussex |
uhz5w | anonymous | Yes | female | 21 | 16 | standard | Sussex |
ulrFC | preview | Yes | female | 18 | 40 | standard | Sussex |
vEL8x | anonymous | Yes | other/pnts | 20 | 45 | standard | Sussex |
vKzBO | anonymous | Yes | other/pnts | 20 | 8 | standard | Sussex |
vhcvY | anonymous | No | female | 19 | 21 | gamified | Sussex |
vr1Ak | anonymous | Yes | female | 18 | 12 | standard | Sussex |
vsJ55 | anonymous | Yes | female | 17 | 20 | standard | Sussex |
w3VSM | anonymous | Yes | female | 16 | NA | gamified | Sussex |
w7s9C | anonymous | Yes | other/pnts | 19 | 18 | gamified | Sussex |
wBIMq | anonymous | Yes | male | 19 | NA | standard | Sussex |
wG2TR | anonymous | Yes | female | 19 | 24 | gamified | Sussex |
wJTzk | anonymous | Yes | other/pnts | 19 | 7 | standard | Sussex |
wUMuo | anonymous | Yes | male | 19 | 16 | standard | Sussex |
wgZsr | anonymous | Yes | other/pnts | 20 | 32 | standard | Sussex |
x7wPc | anonymous | Yes | female | 19 | 20 | standard | Sussex |
x84Lq | anonymous | Yes | female | 19 | NA | gamified | Sussex |
xqMbq | anonymous | Yes | male | 20 | 27 | standard | Sussex |
y9Spo | anonymous | Yes | female | 19 | 32 | standard | Sussex |
yI4K6 | anonymous | Yes | male | 19 | NA | gamified | Sussex |
yIuEJ | anonymous | Yes | female | 18 | 21 | gamified | Sussex |
yOdXf | anonymous | Yes | other/pnts | 18 | NA | standard | Sussex |
yc1im | anonymous | Yes | female | 20 | NA | standard | Sussex |
yf2Sk | anonymous | Yes | other/pnts | 20 | 16 | gamified | Sussex |
ywt26 | anonymous | Yes | other/pnts | 19 | NA | gamified | Sussex |
z3Fm4 | anonymous | No | female | 19 | 40 | gamified | Sussex |
z96zx | anonymous | Yes | female | 21 | 8 | standard | Sussex |
zDLXV | anonymous | Yes | female | 19 | 14 | gamified | Sussex |
zEubx | anonymous | Yes | non-binary | 18 | NA | gamified | Sussex |
zFO0Y | anonymous | Yes | female | 20 | 32 | gamified | Sussex |
zGCo3 | anonymous | Yes | other/pnts | 19 | 14 | gamified | Sussex |
zL7Ou | anonymous | Yes | female | 20 | NA | gamified | Sussex |
zLJmL | anonymous | Yes | female | 21 | 9 | standard | Sussex |
zVpq5 | anonymous | Yes | female | 17 | 45 | gamified | Sussex |
ziCb2 | anonymous | Yes | other/pnts | 19 | 36 | gamified | Sussex |
zwh9W | anonymous | Yes | female | 19 | 36 | gamified | Sussex |
Because this dataset doesn’t have a variable called lab
yet, the variable we’ve created is added as a new column to the dataset (by default, at the end).
Assigning Changes
Before we go on, an absolutely essential step for making changes to a dataset is to assign the changes back to the dataset using the assignment operator, <-
. You may have noticed above that the mutate()
command to create the lab
variable printed out the dataset in the document, but didn’t actually change the mcq_data
object. You can confirm this by clicking on the dataset in your Environment to open the dataset in a new tab, or using any method you like to check the number or names of the variables.
names(mcq_data)
[1] "id" "distribution" "consent" "gender" "age"
[6] "mcq_score" "condition"
If we really wanted to get fancy, we could ask R whether the vector of names of the variables in the dataset contains the name "lab"
, using what we know about logical assertions:
"lab" %in% names(mcq_data)
[1] FALSE
No lab
variable!
That’s expected, because the command we wrote to create the lab
variable didn’t assign the output anywhere. Instead, the output was printed out into the document, but as far as R is concerned, because we didn’t assign that output to an object, it’s like it never happened. If we want to keep the change we made - and we do! - we must assign the output to an object.
Assignment is a critical operation in R, in which the output from a command is stored, or assigned, under an object name. To do this, we use the assignment operator, <-
, which looks like an arrow pointing to the left. The object name that the arrow points at, to the left-hand side of the arrow, is the object that will be created or updated. The output of the instructions on the right-hand side of the arrow is the information that the object will contain. In pseudocode, this looks like:
<- instructions object
If you assign the output of some instructions to an object name that does not currently exist in your Environment, you will create a new object.
If you assign the output of some instructions to an object name that already currently exists in your Environment, you will overwrite the existing object with the new output.
In this case, we want to “update” the mcq_data
object to contain the new variable we’re creating. So, we want to overwrite the existing mcq_data
object with the updated version created by the mutate()
command. To do this, we assign the output of the mutate()
command to the same object name as the existing dataset, like this:
<- dplyr::mutate(
mcq_data
mcq_data,lab = "Sussex"
)
Once we run that, we can check that the variable has been created in the dataset:
"lab" %in% names(mcq_data)
[1] TRUE
Success! The mcq_data
dataset now contains the lab
variable we created.
Task 3
As we noted on our to-do list, create a new variable in the dataset called test_round
, which contains the value “Spring 2024” for all participants. Make sure you update your dataset so that it includes the new variable.
So far we’ve only created constants in our dataset - that is, we’ve created new columns that contain the same value for every participant. Let’s look next at how to create a new variable calculated using other variables in the dataset.
To do this, we follow the same procedure as before. As a reminder, the basic form of the mutate()
function is:
::mutate(
dplyr
dataset_name,variable_name = instructions_for_creating_the_variable
)
We’re going to again create a new variable, but this time we will write the instructions using other variables in the dataset. For this task, we want to apply the same operation for every row, so we can just write the calculation using the variable name2.
From our codebook, we can see that there is a variable missing from our dataset that needs to be calculated, called mcq_perc
. The codebook tells us that this is the raw MCQ score converted to a percentage out of 50. Let’s create it using the existing mcq_score
variable.
Task 4
Create a new mcq_perc
variable in the dataset, using the mcq_score
variable. Make sure you update your dataset so that it includes the new variable.
Conditionals with case_when()
Thus far, the new variables we’ve created with mutate()
apply to every case the same way. So, when we created the test_round
variable, we assigned the same single value to every case; and when we created the mcq_perc
variable, we used the same instructions for every case to calculate the percentage from the score.
However, we might not always want to do the same thing for every case. Sometimes, instead, we might want to assign different values for different cases, depending on their characteristics. This is where the new function dplyr::case_when()
comes in. It can be used to recode the values from one variable into new one, but it can also combine information across variables and handle multiple conditions.
When we mention “recoding” a variable, that essentially means changing the way that the information is expressed. So, for example, if I recode a score into a categorical variable using a cutoff value - as we will do in a moment - I am changing the way the information about score is captured in my dataset.
To use case_when()
, we will create a variable that contains different values depending on some conditions that we set. Those conditions will take the form of….logical assertions, exactly what we were practicing last week! Let’s have a look.
Basic Form
The basic form for creating a new variable using dplyr::case_when()
looks like this:
::mutate(
dplyr
dataset_name,new_variable = dplyr::case_when(
~ value,
logical_assertion .default = value_to_use_for_cases_with_no_matches
) )
Just as we saw above, new_variable
will be the name of the variable that we are creating (or changing). Instead of using a simple expression for our instructions, we instead create those instructions using dplyr::case_when()
.
Inside case_when()
, we first see logical_assertion
, which is any R code that returns TRUE
and FALSE
values. These should be very familiar by now!
value
is the value to put in new_variable
for the cases for which logical_assertion
returns TRUE
.
Overall, you can think of each line in case_when()
as an “if…then…” statement, with multiple lines giving multiple possibilities. So: “If logical_assertion
is true, then (~
) assign value
; otherwise if a_different_logical_assertion
is true, then (~
) assign a_different_value
…” and so on.
The assertions are evaluated sequentially (from first to last in the order they are written in the function), and the first match determines the value. This means that the assertions must be ordered from most specific to least specific.
The assertions for dplyr::case_when()
are the same as the ones we used previously in dplyr::filter()
. In fact, if you need to test the assertion you are writing to ensure that your code will work as you want, you can try the same assertion in dplyr::filter()
to check whether the cases it returns are only and exactly the ones you want to change.
Recoding a Variable
Let’s look at an example of how to use case_when()
to conditionally change the values in a variable.
Previously, we created the mcq_perc
variable, which contains percentage scores (out of 100) on the MCQ exam. Our Codebook, however, also includes an mcq_band
variable, which contains the marking band of the MCQ score. To create this variable, we can use case_when()
to conditionally assign different marking bands to different score ranges.
Let’s get started with an example. First, we can set up the structure of the command using the basic form above, and fill in the dataset and variable names in the right place. Then, let’s write our first logical assertion, assigning any score of 70 or above to the “1st” marking band, and “unassigned” for everything else:
1::mutate(
dplyr
mcq_data,2mcq_band = dplyr::case_when(
3>= 70 ~ "1st",
mcq_perc 4.default = "unassigned"
) )
- 1
-
Make a change to the
mcq_data
dataset as follows: - 2
-
Create a new variable,
mcq_band
, by applying the following criteria. - 3
-
For the cases that have a score in the
mcq_perc
variable that is greater than or equal to 70, assign the value “1st” tomcq_band
. - 4
-
For any remaining cases, assign the value “unassigned” to
mcq_band
.
id | distribution | consent | gender | age | mcq_score | condition | lab | test_round | mcq_perc | mcq_band |
---|---|---|---|---|---|---|---|---|---|---|
0C3da | anonymous | Yes | female | 20 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
0D7OT | anonymous | Yes | other/pnts | 20 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
0Sbvm | anonymous | NA | female | 19 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
0c4cs | anonymous | Yes | female | 20 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
0qtaJ | anonymous | Yes | female | 19 | 8 | gamified | Sussex | Spring 2024 | 16 | unassigned |
0upnc | anonymous | Yes | female | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
11RWE | anonymous | Yes | other/pnts | 18 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
13ECk | anonymous | Yes | female | 18 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
14hab | anonymous | Yes | female | 19 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
17DVa | anonymous | Yes | other/pnts | 19 | 35 | gamified | Sussex | Spring 2024 | 70 | 1st |
1Rn6s | anonymous | Yes | male | 18 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
1U3uo | preview | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
1VTIt | anonymous | Yes | male | 17 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
1YdZV | anonymous | Yes | female | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
1Zycx | anonymous | Yes | other/pnts | 21 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
1crQC | anonymous | Yes | female | 19 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
25pc7 | anonymous | Yes | female | 19 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
2JwwB | anonymous | Yes | female | 20 | 40 | standard | Sussex | Spring 2024 | 80 | 1st |
2Nrw1 | anonymous | Yes | female | 18 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
2Rauy | anonymous | Yes | female | 21 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
2eaqo | anonymous | Yes | female | 19 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
2jBId | anonymous | No | female | 18 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
2jceE | anonymous | Yes | female | 18 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
2nPXu | anonymous | Yes | male | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
2u1pE | anonymous | Yes | female | 19 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
30f1u | anonymous | Yes | female | 18 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
3U4eV | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
3UxFq | anonymous | Yes | female | 19 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
3co3p | anonymous | Yes | non-binary | 19 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
3fsST | anonymous | Yes | female | 60 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
3i2E1 | anonymous | Yes | female | 19 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
3tYkD | anonymous | Yes | female | 230 | 10 | standard | Sussex | Spring 2024 | 20 | unassigned |
42gb3 | anonymous | Yes | other/pnts | 20 | 40 | standard | Sussex | Spring 2024 | 80 | 1st |
4AOOf | anonymous | Yes | female | 20 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
4DdZ7 | anonymous | Yes | female | 20 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
4bD0z | anonymous | NA | other/pnts | 18 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
4fj5T | anonymous | Yes | male | 180 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
4sl1v | anonymous | Yes | male | 17 | 8 | gamified | Sussex | Spring 2024 | 16 | unassigned |
567FX | anonymous | Yes | male | 20 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
57VIy | anonymous | Yes | female | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
5P1SM | anonymous | Yes | female | 21 | 9 | standard | Sussex | Spring 2024 | 18 | unassigned |
5R6kh | anonymous | Yes | female | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
5kwV6 | anonymous | Yes | female | 21 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
604sE | anonymous | Yes | female | 17 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
60RT2 | anonymous | Yes | female | 18 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
6BURB | anonymous | No | other/pnts | 21 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
6eXcl | anonymous | Yes | female | 20 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
6ieyf | anonymous | Yes | female | 20 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
79bUy | anonymous | Yes | female | 37 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
7IBO5 | anonymous | Yes | female | 20 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
7Rnrs | anonymous | Yes | female | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
7aqLl | anonymous | Yes | other/pnts | 17 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
7cNhh | anonymous | Yes | female | 19 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
7nmrS | anonymous | Yes | male | 20 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
7q2mO | anonymous | Yes | female | 20 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
7q31O | anonymous | NA | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
7suHW | anonymous | Yes | female | 17 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
8FULZ | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
8NDBN | anonymous | Yes | female | 20 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
8QRNK | anonymous | Yes | non-binary | 18 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
8VtOH | anonymous | Yes | female | 21 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
8a4cQ | anonymous | Yes | female | 18 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
8gZ4N | anonymous | Yes | male | 20 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
8njXv | preview | NA | female | 18 years | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
8oJjk | anonymous | Yes | female | 18 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
91elw | anonymous | Yes | male | 19 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
9C8jB | anonymous | Yes | other/pnts | 19 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
9JizO | anonymous | Yes | male | 20 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
9eSGk | anonymous | Yes | female | 20 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
9kScn | anonymous | Yes | female | 20 | 50 | gamified | Sussex | Spring 2024 | 100 | 1st |
9mpUu | anonymous | Yes | other/pnts | 52 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
9vOj2 | anonymous | Yes | other/pnts | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
A0bdM | anonymous | Yes | female | 20 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
A3fBz | anonymous | Yes | other/pnts | 26 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
AB3Ij | anonymous | Yes | female | 19 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
ABIG8 | anonymous | Yes | female | 18 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
AIDGD | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
AMVGF | anonymous | Yes | other/pnts | 20 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
AU8Xf | anonymous | Yes | female | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
B3sQT | anonymous | Yes | male | 20 years old | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
B9ptw | anonymous | Yes | female | 18 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
BD5VH | anonymous | Yes | female | 17 | 35 | standard | Sussex | Spring 2024 | 70 | 1st |
BKRNd | anonymous | Yes | female | 19 | 22 | standard | Sussex | Spring 2024 | 44 | unassigned |
BLQ0T | anonymous | Yes | other/pnts | 19 | 12 | gamified | Sussex | Spring 2024 | 24 | unassigned |
BMp5i | anonymous | Yes | female | 18 | 45 | standard | Sussex | Spring 2024 | 90 | 1st |
BOAq9 | anonymous | Yes | other/pnts | 20 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
BQzv9 | anonymous | Yes | female | 20 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
BT3yn | anonymous | Yes | other/pnts | 17 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
BaEJT | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
Bawej | anonymous | Yes | male | 18 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
BwZMT | anonymous | Yes | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
BxoYr | anonymous | Yes | male | 19 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
C0uUo | anonymous | Yes | female | 20 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
C2yd8 | anonymous | Yes | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
C7cZS | anonymous | Yes | other/pnts | 20 | 35 | gamified | Sussex | Spring 2024 | 70 | 1st |
CNnTV | anonymous | NA | female | 210 | 7 | gamified | Sussex | Spring 2024 | 14 | unassigned |
CWz9G | anonymous | Yes | female | 22 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
CXCEY | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
CZAvP | anonymous | Yes | female | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
CZkx0 | anonymous | Yes | female | 20 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
CkUqi | anonymous | Yes | female | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
Cntlm | anonymous | Yes | female | 18 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
D09VK | preview | Yes | female | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
D27tu | anonymous | Yes | female | 20 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
D4Ouu | anonymous | Yes | female | 32 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
D8xUm | anonymous | Yes | female | 20 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
DKWAC | anonymous | Yes | male | 18 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
DNVaD | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
DQMDF | anonymous | Yes | female | 19 | 40 | standard | Sussex | Spring 2024 | 80 | 1st |
DR76B | anonymous | Yes | female | 20 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
DSXgx | anonymous | Yes | female | 21 | 35 | gamified | Sussex | Spring 2024 | 70 | 1st |
DcHno | anonymous | Yes | female | 20 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
DoFNW | anonymous | Yes | other/pnts | 18 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
DoH5g | anonymous | No | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
DxQWx | anonymous | Yes | female | 20 | 6 | gamified | Sussex | Spring 2024 | 12 | unassigned |
EBecP | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
EGFk2 | anonymous | Yes | female | 18 | 9 | gamified | Sussex | Spring 2024 | 18 | unassigned |
ELGp5 | anonymous | Yes | male | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
EPLlm | anonymous | Yes | female | 19 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
EjbZG | anonymous | No | male | 19 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
EjpDL | anonymous | Yes | female | 18 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
Er8lG | anonymous | Yes | female | 18 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
F6UhY | anonymous | Yes | female | 18 | 8 | standard | Sussex | Spring 2024 | 16 | unassigned |
FEPUM | anonymous | Yes | female | 19 | 35 | standard | Sussex | Spring 2024 | 70 | 1st |
FHqks | anonymous | Yes | female | 19 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
FLUxb | anonymous | Yes | female | 18 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
FQ9jA | anonymous | Yes | female | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
FXs3X | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
FY4Qd | anonymous | Yes | female | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
FgC2w | anonymous | Yes | other/pnts | 20 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
Fv6Hm | anonymous | Yes | female | 19 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
FxA3a | anonymous | Yes | other/pnts | 20 | 0 | standard | Sussex | Spring 2024 | 0 | unassigned |
G750q | anonymous | Yes | female | 18 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
GF7AW | anonymous | Yes | female | 18 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
GIdfy | anonymous | Yes | other/pnts | 20 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
GPeCC | anonymous | Yes | female | 20 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
GXFHo | anonymous | Yes | female | 18 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
GtuVx | anonymous | Yes | female | 18 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
GwzPE | preview | Yes | non-binary | 19 | 12 | gamified | Sussex | Spring 2024 | 24 | unassigned |
H0grb | anonymous | Yes | female | 19 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
Htlec | anonymous | Yes | male | 190 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
IB3jV | anonymous | Yes | other/pnts | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
IJpxI | anonymous | Yes | male | 20 | 8 | standard | Sussex | Spring 2024 | 16 | unassigned |
IaQTG | anonymous | Yes | female | 19 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
ItPc5 | anonymous | Yes | other/pnts | 19 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
IxAfx | anonymous | Yes | female | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
IxCJg | anonymous | Yes | other/pnts | 19 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
IybPq | anonymous | Yes | female | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
J5rW4 | anonymous | Yes | female | 20 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
Jb4Zj | anonymous | Yes | other/pnts | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
Jfu4H | anonymous | NA | male | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
JmGnA | anonymous | Yes | female | 19 | 45 | standard | Sussex | Spring 2024 | 90 | 1st |
K4ccy | anonymous | Yes | female | 19 | 40 | standard | Sussex | Spring 2024 | 80 | 1st |
K4cqA | anonymous | Yes | female | 20 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
K5AI8 | anonymous | Yes | female | 20 | 30 | gamified | Sussex | Spring 2024 | 60 | unassigned |
K6WAN | anonymous | Yes | female | 21 | 30 | standard | Sussex | Spring 2024 | 60 | unassigned |
KH29p | anonymous | Yes | female | 19 | 0 | gamified | Sussex | Spring 2024 | 0 | unassigned |
KJnFK | anonymous | Yes | female | 18 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
KQSrs | preview | NA | male | 21 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
KaPny | anonymous | Yes | male | 19 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
KarR9 | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
KcUpk | anonymous | Yes | female | 18 | 12 | gamified | Sussex | Spring 2024 | 24 | unassigned |
Kf7xs | anonymous | Yes | female | 18 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
KjaQK | anonymous | Yes | female | 18 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
L0CPk | anonymous | Yes | other/pnts | 18 | 20 | standard | Sussex | Spring 2024 | 40 | unassigned |
L4Qxw | anonymous | Yes | male | 19 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
LONaU | anonymous | Yes | female | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
LYiMm | anonymous | Yes | other/pnts | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
LZPJq | anonymous | Yes | female | 19 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
Ljcpu | anonymous | Yes | other/pnts | 24 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
LlCNK | anonymous | Yes | female | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
M2MI0 | anonymous | Yes | other/pnts | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
M4BLy | anonymous | Yes | female | 18 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
M8Oxv | anonymous | Yes | female | 19 | 9 | standard | Sussex | Spring 2024 | 18 | unassigned |
MBn1k | anonymous | Yes | female | 21 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
MFJt5 | anonymous | Yes | male | 21 | 0 | standard | Sussex | Spring 2024 | 0 | unassigned |
MIov5 | anonymous | Yes | other/pnts | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
MZjPB | anonymous | NA | non-binary | 19 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
MhO9r | anonymous | Yes | male | 19 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
MuIEO | anonymous | Yes | male | 22 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
N0jIl | anonymous | Yes | female | 17 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
N6FTh | anonymous | Yes | female | 19 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
NdYHw | anonymous | Yes | male | 17 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
NqFOx | anonymous | Yes | male | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
O5JsZ | anonymous | Yes | male | 19 | 20 | standard | Sussex | Spring 2024 | 40 | unassigned |
O8CdZ | anonymous | Yes | female | 19 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
OGIx2 | anonymous | Yes | female | 22 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
OXSGm | anonymous | Yes | female | 20 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
Ovi8C | anonymous | Yes | female | 20 | 12 | gamified | Sussex | Spring 2024 | 24 | unassigned |
OygRR | anonymous | Yes | female | 19 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
PHYsH | anonymous | Yes | female | 19 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
PWZd9 | anonymous | Yes | female | 19 | 40 | standard | Sussex | Spring 2024 | 80 | 1st |
QDq3A | anonymous | Yes | female | 49 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
QDtKQ | anonymous | Yes | female | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
QQVJe | anonymous | Yes | female | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
Qcugp | anonymous | Yes | female | 34 | 35 | gamified | Sussex | Spring 2024 | 70 | 1st |
QpLrh | anonymous | Yes | female | 19 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
R2B6T | anonymous | Yes | non-binary | 20 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
R2Y7E | anonymous | Yes | female | 220 | 45 | gamified | Sussex | Spring 2024 | 90 | 1st |
R47v6 | anonymous | Yes | other/pnts | 18 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
RCDNX | anonymous | Yes | female | 18 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
RFJnJ | anonymous | Yes | female | 19 | 9 | standard | Sussex | Spring 2024 | 18 | unassigned |
RKrjC | anonymous | Yes | female | 21 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
RVUhK | anonymous | Yes | female | 19 | 35 | gamified | Sussex | Spring 2024 | 70 | 1st |
RhYFX | anonymous | Yes | other/pnts | 20 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
RxCMC | anonymous | Yes | female | 18 | 8 | gamified | Sussex | Spring 2024 | 16 | unassigned |
SAkjm | anonymous | Yes | male | 20 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
SZWB3 | anonymous | Yes | female | 18 | 45 | gamified | Sussex | Spring 2024 | 90 | 1st |
SaC0c | anonymous | Yes | female | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
TAtlY | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
Td2sp | anonymous | Yes | other/pnts | 43 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
Tvu4K | anonymous | Yes | other/pnts | 47 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
U7rUC | anonymous | Yes | female | 20 | 0 | standard | Sussex | Spring 2024 | 0 | unassigned |
UJPCB | preview | Yes | female | 18 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
UUvvR | anonymous | Yes | female | 18 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
UfHKg | preview | Yes | other/pnts | 18 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
UoCiQ | anonymous | Yes | female | 44 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
UsFJA | anonymous | Yes | other/pnts | 21 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
VAsax | anonymous | Yes | male | 19 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
VAzZ4 | preview | Yes | female | 19 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
VEsAZ | anonymous | Yes | female | 20 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
VFHCz | anonymous | Yes | female | 18 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
VLNR8 | anonymous | Yes | female | 19 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
VSXkO | anonymous | Yes | female | 19 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
VX0eQ | anonymous | Yes | female | 19 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
VZ8g2 | anonymous | Yes | other/pnts | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
Vauqd | anonymous | Yes | female | 18 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
Vgbl2 | anonymous | Yes | female | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
VpL9v | anonymous | No | female | 19 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
VrH7Z | anonymous | Yes | female | 19 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
Vu8ja | anonymous | Yes | female | 20 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
W0GJa | anonymous | Yes | female | 20 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
WBwEl | anonymous | Yes | female | 18 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
WFtTV | anonymous | Yes | female | 21 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
WIBkj | anonymous | Yes | male | 18 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
WRhXk | anonymous | NA | female | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
WZeXp | anonymous | Yes | female | 19 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
Wa4i1 | anonymous | Yes | male | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
WdOtI | anonymous | Yes | male | 18 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
WhMr1 | anonymous | Yes | female | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
WkVff | anonymous | Yes | male | 20 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
Wkczy | anonymous | Yes | male | 42 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
WpZoF | anonymous | Yes | female | 20 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
WrbdV | anonymous | Yes | female | 20 | 7 | standard | Sussex | Spring 2024 | 14 | unassigned |
WvTTm | anonymous | Yes | female | 19 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
Wxab9 | anonymous | Yes | female | 46 | 14 | standard | Sussex | Spring 2024 | 28 | unassigned |
WzwfL | anonymous | Yes | female | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
X4X9u | anonymous | Yes | female | 19 | 8 | gamified | Sussex | Spring 2024 | 16 | unassigned |
X94fv | anonymous | Yes | female | 21 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
XMUsl | anonymous | Yes | male | 20 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
XNla5 | anonymous | Yes | female | 19 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
XRmHi | anonymous | Yes | female | 19 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
XTNNv | anonymous | Yes | female | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
XdQAZ | anonymous | Yes | other/pnts | 21 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
XdULZ | anonymous | Yes | other/pnts | 18 | 6 | gamified | Sussex | Spring 2024 | 12 | unassigned |
Xhe8o | anonymous | Yes | female | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
Y4hX5 | anonymous | Yes | other/pnts | 17 | 30 | gamified | Sussex | Spring 2024 | 60 | unassigned |
Y9l70 | anonymous | Yes | female | 19 | 45 | gamified | Sussex | Spring 2024 | 90 | 1st |
YBBpv | anonymous | Yes | male | 20 | 10 | standard | Sussex | Spring 2024 | 20 | unassigned |
YDlvy | anonymous | Yes | female | 39 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
YI5OX | preview | Yes | male | 23 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
YJiyx | anonymous | Yes | male | 18 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
YyvSr | anonymous | Yes | female | 20 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
Z3D1i | anonymous | Yes | female | 18 | 30 | standard | Sussex | Spring 2024 | 60 | unassigned |
Z5pG4 | anonymous | Yes | female | 20 | 35 | standard | Sussex | Spring 2024 | 70 | 1st |
ZdlsP | anonymous | Yes | female | 17 | 30 | standard | Sussex | Spring 2024 | 60 | unassigned |
ZfbJ5 | anonymous | No | other/pnts | 19 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
Zikvz | anonymous | Yes | female | 20 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
ZmXSs | anonymous | Yes | female | 18 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
aLaPg | anonymous | Yes | male | 18 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
adPdh | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
aeqF8 | anonymous | Yes | female | 20 | 30 | gamified | Sussex | Spring 2024 | 60 | unassigned |
ajiJb | anonymous | NA | female | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
an4Bk | anonymous | Yes | male | 18 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
asHWN | anonymous | Yes | female | 20 | 35 | gamified | Sussex | Spring 2024 | 70 | 1st |
bWJ9P | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
bbEVT | anonymous | Yes | other/pnts | 20 | 9 | gamified | Sussex | Spring 2024 | 18 | unassigned |
bq9vF | anonymous | Yes | other/pnts | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
cF65b | anonymous | Yes | female | 20 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
cLK5b | anonymous | Yes | female | 17 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
caofW | anonymous | Yes | female | 20 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
cwMSQ | anonymous | Yes | female | 19 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
d4rJu | anonymous | Yes | other/pnts | 57 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
dGttD | anonymous | Yes | male | 21 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
dSPKO | anonymous | Yes | female | 20 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
daDjs | anonymous | Yes | female | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
dl5cO | anonymous | Yes | female | 51 | 7 | standard | Sussex | Spring 2024 | 14 | unassigned |
dtOna | anonymous | Yes | male | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
eFBcM | anonymous | NA | female | 19 | 8 | standard | Sussex | Spring 2024 | 16 | unassigned |
eGI1r | anonymous | Yes | other/pnts | 20 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
eXXqe | anonymous | Yes | female | 20 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
fCUzB | anonymous | Yes | female | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
fIkUH | anonymous | Yes | male | 18 | 45 | gamified | Sussex | Spring 2024 | 90 | 1st |
fL8q6 | anonymous | No | female | 19 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
fMpxN | anonymous | Yes | female | 20 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
fXyk6 | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
faZaK | anonymous | Yes | female | 18 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
fevx8 | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
fvTHz | anonymous | Yes | female | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
fyRug | anonymous | Yes | other/pnts | 20 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
fysPC | anonymous | Yes | female | 20 | 9 | gamified | Sussex | Spring 2024 | 18 | unassigned |
gEk8c | anonymous | Yes | female | 20 | 45 | gamified | Sussex | Spring 2024 | 90 | 1st |
gFk3j | anonymous | Yes | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
gLGEb | anonymous | Yes | female | 20 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
gTwyG | anonymous | Yes | other/pnts | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
gbS51 | anonymous | Yes | female | 20 | 8 | standard | Sussex | Spring 2024 | 16 | unassigned |
getql | anonymous | Yes | female | 20 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
gys2m | anonymous | Yes | female | 19 | 0 | gamified | Sussex | Spring 2024 | 0 | unassigned |
h9bgT | anonymous | Yes | female | 21 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
hAk7r | anonymous | Yes | female | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
hL89D | anonymous | Yes | other/pnts | 18 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
hO1d9 | anonymous | Yes | female | 18 | 8 | gamified | Sussex | Spring 2024 | 16 | unassigned |
hVnBV | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
hvnBr | anonymous | No | female | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
hwSwZ | anonymous | Yes | female | 19 | 33 | standard | Sussex | Spring 2024 | 66 | unassigned |
i59RR | anonymous | NA | other/pnts | 20 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
iCrQN | anonymous | Yes | female | 19 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
iD9hw | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
iPxF0 | anonymous | Yes | female | 19 | 20 | gamified | Sussex | Spring 2024 | 40 | unassigned |
iXfgl | anonymous | Yes | female | 18 | 6 | standard | Sussex | Spring 2024 | 12 | unassigned |
iZ5Ke | anonymous | Yes | other/pnts | 54 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
il39l | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
j7KVe | anonymous | Yes | female | 20 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
jHGu5 | anonymous | Yes | female | 45 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
jLARq | anonymous | Yes | other/pnts | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
jSyAN | anonymous | Yes | other/pnts | 17 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
jWq9O | anonymous | Yes | female | 18 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
jf3nH | anonymous | Yes | female | 20 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
jgRNK | anonymous | Yes | female | 19 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
ji41d | anonymous | Yes | female | 16 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
jmLsY | anonymous | Yes | female | 18 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
jmwSi | anonymous | Yes | female | 18 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
jrDKg | anonymous | Yes | female | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
jtMtP | anonymous | Yes | female | 18 | 6 | gamified | Sussex | Spring 2024 | 12 | unassigned |
k6UDx | anonymous | Yes | male | 19 | 8 | standard | Sussex | Spring 2024 | 16 | unassigned |
kEP1V | anonymous | Yes | non-binary | 53 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
kMNiI | anonymous | Yes | female | 20 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
kPaPZ | anonymous | Yes | female | 19 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
kRMUF | anonymous | Yes | female | 19 | 7 | standard | Sussex | Spring 2024 | 14 | unassigned |
kS1iR | anonymous | Yes | female | 18 | 9 | standard | Sussex | Spring 2024 | 18 | unassigned |
kYoLp | anonymous | Yes | female | 21 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
kcnVj | anonymous | Yes | female | 19 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
khOxC | anonymous | Yes | female | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
kl0sP | anonymous | Yes | female | 18 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
kmG6j | anonymous | Yes | female | 19 | 20 | standard | Sussex | Spring 2024 | 40 | unassigned |
kytPK | anonymous | Yes | other/pnts | 19 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
l60b2 | anonymous | Yes | female | 20 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
lGp5b | anonymous | Yes | female | 17 | 9 | standard | Sussex | Spring 2024 | 18 | unassigned |
lWSMK | anonymous | NA | female | 19 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
lZYPj | anonymous | Yes | male | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
leQj6 | anonymous | No | female | 20 | 8 | standard | Sussex | Spring 2024 | 16 | unassigned |
llurT | anonymous | Yes | female | 18 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
loO7K | anonymous | Yes | female | 21 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
lvGzW | anonymous | Yes | female | 19 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
lyC9q | anonymous | Yes | male | 18 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
m2Dcx | anonymous | Yes | female | 17 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
m5atb | anonymous | No | other/pnts | 18 | 45 | gamified | Sussex | Spring 2024 | 90 | 1st |
m7RM9 | anonymous | NA | male | 20 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
mNfOf | anonymous | Yes | female | 20 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
mRJfz | anonymous | Yes | female | 18 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
mUe2L | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
mVFza | anonymous | Yes | other/pnts | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
mWF7h | anonymous | Yes | other/pnts | 18 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
mfTib | anonymous | Yes | female | 20 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
mgU6J | anonymous | Yes | female | 18 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
mm5mY | anonymous | Yes | male | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
mw4Kf | anonymous | Yes | female | 19 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
n33R4 | anonymous | Yes | female | 27 | 36 | standard | Sussex | Spring 2024 | 72 | 1st |
n4R4P | anonymous | Yes | female | 19 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
n5DlS | anonymous | NA | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
nQtEb | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
nRG2C | preview | NA | female | 20 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
nSNLc | anonymous | Yes | female | 17 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
njgt8 | anonymous | Yes | female | 20 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
nm9bk | anonymous | Yes | female | 17 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
no5PW | anonymous | Yes | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
noVdw | anonymous | Yes | female | 48 | 45 | gamified | Sussex | Spring 2024 | 90 | 1st |
nyaYZ | anonymous | Yes | female | 20 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
o0nLV | preview | Yes | female | 19 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
oGu48 | anonymous | Yes | other/pnts | 18 | 28 | standard | Sussex | Spring 2024 | 56 | unassigned |
oRz5N | anonymous | Yes | female | 18 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
oTapN | anonymous | Yes | male | 18 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
oYLJv | anonymous | No | female | 19 | 20 | standard | Sussex | Spring 2024 | 40 | unassigned |
ocAbh | anonymous | NA | male | 18 | 12 | standard | Sussex | Spring 2024 | 24 | unassigned |
ouFFF | anonymous | Yes | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
p4ZE3 | anonymous | Yes | female | 200 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
pQZlb | anonymous | Yes | male | 18 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
pXcHr | anonymous | Yes | female | 21 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
pnZuQ | anonymous | Yes | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
qHA0y | anonymous | NA | female | 18 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
qIdkI | anonymous | Yes | other/pnts | 18 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
qN6C4 | anonymous | Yes | female | 18 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
qN9TW | anonymous | NA | female | 21 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
qQwMw | preview | Yes | female | 20 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
qXrrA | anonymous | Yes | male | 20 | 30 | gamified | Sussex | Spring 2024 | 60 | unassigned |
qYYts | anonymous | Yes | female | 21 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
qb9LW | anonymous | Yes | other/pnts | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
qejj5 | anonymous | Yes | female | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
qhsfF | anonymous | Yes | female | 18 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
qkyKI | anonymous | Yes | female | 17 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
qtaGK | anonymous | Yes | other/pnts | 19 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
r50GM | anonymous | Yes | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
rDPQX | anonymous | Yes | female | 20 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
rFHo4 | anonymous | NA | female | 20 | 50 | gamified | Sussex | Spring 2024 | 100 | 1st |
rOXvR | anonymous | No | female | 19 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
rcnu3 | anonymous | Yes | other/pnts | 20 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
rhVte | anonymous | Yes | other/pnts | 20 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
rriRG | anonymous | Yes | female | 19 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
s4P5c | anonymous | NA | female | 17 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
s94aP | anonymous | Yes | female | 19 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
sMnDB | anonymous | Yes | female | 21 | 24 | standard | Sussex | Spring 2024 | 48 | unassigned |
sXQ1a | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
seB6W | anonymous | Yes | male | 20 | 18 | standard | Sussex | Spring 2024 | 36 | unassigned |
smrQ6 | anonymous | Yes | other/pnts | 21 | 28 | gamified | Sussex | Spring 2024 | 56 | unassigned |
swu32 | anonymous | Yes | female | 20 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
sxLaB | anonymous | Yes | female | 21 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
t1mfp | anonymous | Yes | female | 55 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
t78FX | anonymous | Yes | female | 19 | 45 | standard | Sussex | Spring 2024 | 90 | 1st |
tNLJ3 | anonymous | Yes | female | 20 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
tNuov | anonymous | Yes | female | 20 | 21 | standard | Sussex | Spring 2024 | 42 | unassigned |
tP3EH | anonymous | Yes | male | 19 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
tPgph | anonymous | Yes | female | 20 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
tRubH | anonymous | Yes | non-binary | 21 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
td473 | anonymous | No | male | 18 | 12 | standard | Sussex | Spring 2024 | 24 | unassigned |
tiMsW | anonymous | Yes | female | 20 | 9 | standard | Sussex | Spring 2024 | 18 | unassigned |
u4hGl | anonymous | Yes | female | 36 | 27 | gamified | Sussex | Spring 2024 | 54 | unassigned |
uEu4N | anonymous | Yes | female | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
uQ6Yl | anonymous | Yes | female | 19 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
uaJGu | anonymous | Yes | male | 20 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
ubxCE | anonymous | Yes | other/pnts | 18 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
ucGBA | anonymous | Yes | female | 19 | 9 | standard | Sussex | Spring 2024 | 18 | unassigned |
udr3I | anonymous | Yes | other/pnts | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
uhz5w | anonymous | Yes | female | 21 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
ulrFC | preview | Yes | female | 18 | 40 | standard | Sussex | Spring 2024 | 80 | 1st |
vEL8x | anonymous | Yes | other/pnts | 20 | 45 | standard | Sussex | Spring 2024 | 90 | 1st |
vKzBO | anonymous | Yes | other/pnts | 20 | 8 | standard | Sussex | Spring 2024 | 16 | unassigned |
vhcvY | anonymous | No | female | 19 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
vr1Ak | anonymous | Yes | female | 18 | 12 | standard | Sussex | Spring 2024 | 24 | unassigned |
vsJ55 | anonymous | Yes | female | 17 | 20 | standard | Sussex | Spring 2024 | 40 | unassigned |
w3VSM | anonymous | Yes | female | 16 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
w7s9C | anonymous | Yes | other/pnts | 19 | 18 | gamified | Sussex | Spring 2024 | 36 | unassigned |
wBIMq | anonymous | Yes | male | 19 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
wG2TR | anonymous | Yes | female | 19 | 24 | gamified | Sussex | Spring 2024 | 48 | unassigned |
wJTzk | anonymous | Yes | other/pnts | 19 | 7 | standard | Sussex | Spring 2024 | 14 | unassigned |
wUMuo | anonymous | Yes | male | 19 | 16 | standard | Sussex | Spring 2024 | 32 | unassigned |
wgZsr | anonymous | Yes | other/pnts | 20 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
x7wPc | anonymous | Yes | female | 19 | 20 | standard | Sussex | Spring 2024 | 40 | unassigned |
x84Lq | anonymous | Yes | female | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
xqMbq | anonymous | Yes | male | 20 | 27 | standard | Sussex | Spring 2024 | 54 | unassigned |
y9Spo | anonymous | Yes | female | 19 | 32 | standard | Sussex | Spring 2024 | 64 | unassigned |
yI4K6 | anonymous | Yes | male | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
yIuEJ | anonymous | Yes | female | 18 | 21 | gamified | Sussex | Spring 2024 | 42 | unassigned |
yOdXf | anonymous | Yes | other/pnts | 18 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
yc1im | anonymous | Yes | female | 20 | NA | standard | Sussex | Spring 2024 | NA | unassigned |
yf2Sk | anonymous | Yes | other/pnts | 20 | 16 | gamified | Sussex | Spring 2024 | 32 | unassigned |
ywt26 | anonymous | Yes | other/pnts | 19 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
z3Fm4 | anonymous | No | female | 19 | 40 | gamified | Sussex | Spring 2024 | 80 | 1st |
z96zx | anonymous | Yes | female | 21 | 8 | standard | Sussex | Spring 2024 | 16 | unassigned |
zDLXV | anonymous | Yes | female | 19 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
zEubx | anonymous | Yes | non-binary | 18 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
zFO0Y | anonymous | Yes | female | 20 | 32 | gamified | Sussex | Spring 2024 | 64 | unassigned |
zGCo3 | anonymous | Yes | other/pnts | 19 | 14 | gamified | Sussex | Spring 2024 | 28 | unassigned |
zL7Ou | anonymous | Yes | female | 20 | NA | gamified | Sussex | Spring 2024 | NA | unassigned |
zLJmL | anonymous | Yes | female | 21 | 9 | standard | Sussex | Spring 2024 | 18 | unassigned |
zVpq5 | anonymous | Yes | female | 17 | 45 | gamified | Sussex | Spring 2024 | 90 | 1st |
ziCb2 | anonymous | Yes | other/pnts | 19 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
zwh9W | anonymous | Yes | female | 19 | 36 | gamified | Sussex | Spring 2024 | 72 | 1st |
As you can see, only the cases that match the logical assertion (scores of 70 or higher in mcq_perc
) have the value “1st” in mcq_band
.
Now we’re not done of course - we still need to assign marking bands for the remaining scores.
Task 5
Create the mcq_band
variable by completing case_when()
with the following requirements. Make sure you assign the output to the dataset so that it includes the new variable.
- 70 and above: 1st
- 60 and above: 2.1
- 50 and above: 2.2
- 40 and above: 3rd
- Below 40: Fail
Note that these logical statements are overlapping. For example, someone who scored a 58 matches the condition for “2.2” and “3rd” (58 is greater than or equal to both 50 and 40!). However, that case would only get a single value, “2.2”. This is because the logical statements are evaluated in order, and once they match one of the statements, they are ignored by any subsequent statements.
Fixing Variables with Problems
For the last required task in this tutorial, we’re going to bring together everything we’ve learned in this and last week to tackle the last outstanding case: that problematic age
variable.
The age
variable, which should be a numeric variable according to the Codebook, is actually a character variable. This suggests something has gone wrong with the reading-in. Let’s get counts of the values in this variable first, using dplyr::count()
. This handy little function will count the unique values of a variable for you, using the basic form:
::count(dataset_name, variable_name) dplyr
So, to get counts of all of the values in the age
variable, we can use the following command:
::count(mcq_data, age) dplyr
# A tibble: 39 × 2
age n
<chr> <int>
1 16 2
2 17 21
3 18 94
4 18 years 1
5 180 1
6 19 168
7 190 1
8 20 117
9 20 years old 1
10 200 1
# ℹ 29 more rows
Looking through the output, we might notice a couple things. There are some weird values in there (some people are centuries old!), but those are still numbers, so that’s not what is causing the variable to have the wrong data type. Instead, the issue is that there are a couple cases who included words in their ages: “20 years old” and “18 years”. Because these values contain words (characters), R has changed every value in the age
variable to be character type! This sort of thing happens all the time - it’s exactly the kind of problem you might encounter with your dissertation data. Let’s think through the steps to resolve it:
- First, we have to change the problematic values in
age
, while leaving the rest of the values the same. In this instance, let’s change the problem values to 20 and 18, because it’s clear what they intended to write. (If it was not clear what age they intended - for example, if they had left it blank or put an improbable age, like 230, it would be better to remove them instead.) - Next, once we have changed all the problematic values, we need to explicitly tell R to convert the data into numeric type.
- Finally, we should check that this has worked using
count()
,summary()
, and/or other functions.
To get you started, let’s have a look at the first part of the first step. To get set up, we again use the basic form and replace the names of the dataset and variables.
1::mutate(
dplyr
mcq_data,2age = dplyr::case_when(
3== "20 years old" ~ "20",
age 4.default = age
) )
- 1
-
Make a change to the
mcq_data
dataset as follows: - 2
-
Overwrite the existing variable,
age
, by applying the following criteria. - 3
-
For the cases that have a value in the
age
variable that is exactly equal to “20 years old”, assign the value “20” toage
. - 4
-
For any remaining cases, assign the existing value from the
age
variable.
There are three things to note about this command. The first is that the variable name that we are creating with mutate()
is the same as the variable name, age
, that already exists in the dataset. This means that instead of creating a new variable, we will instead overwrite the existing age
variable with the new one.
The second is that even though we want a numeric value in age
, I’ve replaced the value with "20"
instead of 20
. This is because, at the moment, the variable is character type, so we have to use quotes (for now).
The last thing to notice is the line .default = age
. This might look a bit strange, but it’s extremely useful because we only want to change a few individual cases. By setting .default
to be the existing variable, we are essentially saying, “Use the same values that already exist in this variable by default, once you’ve changed the individual cases that need updating.”
Task 6
Finish fixing the age
variable by completing the following steps:
- Update the
mutate()
command above to also fix the problem value “18 years”. - Convert the
age
variable into numeric using theas.numeric()
function. - Make sure you update your dataset so that it implements your changes!
- Confirm that the
age
variable is now numeric and no longer contains any non-number values.
This is a tough task, but you can do it with what we’ve covered in this tutorial!
Very well done getting to the end! We will keep practicing the mutate/case_when combo throughout this module, so it’s fantastic that you’re putting in the work now to get a strong foundation. If you want even more practice - and some extra Kahoot! points - try taking on this week’s ChallengR as well.
ChallengR
This task is a ChallengR, which are always optional, and will never be assessed - they’re only there to inspire you to try new things! If you solve this task successfully, you can earn a bonus 2500 Kahoot Points. You can use those points to earn bragging rights and, more importantly, shiny stickers. (See the Games and Awards page on Canvas.)
There are no solutions in this document for this ChallengR task. If you get stuck, ask us for help in your practicals or at the Help Desk, and we’ll be happy to point you in the right direction.
We’ve looked at a couple examples now of using filter()
to clean datasets by removing cases that need to be excluded. However, that’s really only part of the picture. When you do your data analysis for real, for example for your dissertation, you must not only clean your data but also report your exclusions carefully. This means that you must report in your dissertation how many people you removed for each reason - how many responded but didn’t consent, how many were too young, etc.
To do this, instead of filtering them out in the first instance - which doesn’t keep any record of who we have excluded and why - we might also like to create a useful coding variable to help keep track of the number of cases we’ve removed, and for what reasons. We can draw on input from multiple variables to create this single new variable using the mutate + case_when combo.
Task 7
Create a new variable in the dataset called exclude
. This variable should contain either the value “keep” (for cases that should be retained) or a short description of their reason for removal (for cases that should be removed). These reasons include:
- “preview” for cases from preview runs (i.e. that are not real data)
- “no_consent” for cases that did not actively consent to participate
- “age_young” for cases that reported an age below the ethical low-risk age limit
- “age_weird” for cases that reported an age that was inadmissable for other reasons - for instance, was missing, or was oddly high (e.g. 210)
- Use the Codebook to decide on a sensible cutoff.
Once you’ve completed the changes and created the exclude
variable in your dataset, run the code chunk below exactly as it is - don’t change anything! If you completed the task correctly, it will reveal a passcode that will grant you 2500 Kahoot points.
|>
mcq_data ::filter(exclude == "age_weird") |>
dplyr::pull(id) |>
dplyrpaste0(collapse = "_")
To redeem your points, copy the output above and paste it as the passcode into the Week 2 ChallengR Canvas quiz. Don’t include the [1]
or quotes. Well done!
Footnotes
Here, “silently” means that R overwrites the existing variable without flagging that it is doing this or asking you if you are sure, so it’s important to be aware of this behaviour (and to know what variables already exist in your dataset).↩︎
If this distinction doesn’t make a lot of sense yet, it will in a moment when we get to
case_when()
!↩︎