Open instructor resources
The original teaching guide, rubric, Lesson 0 worked answers and instructor R script are available without a private sign-in. Open Instructor Desk · Lesson 0 answers.
Identifiable student records and original UCL files without redistribution permission are not republished.
Before the lesson · 5–10 minutes
- Check access to R and RStudio and open a script. This preparation is outside the 90-minute lesson.
- Keep three tabs ready: Lesson 0, PALS Week 1 code guide, and Lesson 1 student practice.
- Open the student’s original Week 1 file only from their own private location. The original UCL materials and identifiable student information must not be uploaded here. Our synthetic instructor solutions are publicly available separately.
First-lesson goal: the student creates an object/vector, explains a function and the effect of NA, and selects a data column.
90-minute sequence
Times are minutes from the start of the lesson; preparation is separate.
00–088 min
Welcome, set a goal and open the tools
Do and show
- Ask the student to open RStudio and their own R script. Show Script and Console; have them run a line with Ctrl+Enter (Cmd+Enter on Mac).
- Open the problem / algorithm / R / RStudio distinction in Lesson 0. Today’s goal is to read, write and explain simple code.
Ask: “Are R and RStudio the same? Before running a line, can you say what you expect it to do?”
If setup fails, predict the steps on paper and note the setup issue separately. Do not count the code as executed.
08–1810 min
Starting check: predict → run → explain
Ask the student to read and predict before running each line themselves.
x <- c(2, 4, 6)
mean(x)
mean(c(2, NA, 6))
Ask: “What does <- assign, and where? What does c() do? Why might the final line not return a number?”
Decision: If objects, averages or NA are unclear, slow down during minutes 18–45; if the student explains them confidently, shorten the examples and use the advanced option at 60–75. This is not a graded test.
Open: Week 1 code guide →
18–3012 min
Describe the problem before coding
Open Lesson 0: problem and algorithm. Ask the student to describe, without code, how to identify missing questionnaire responses and calculate a mean.
Ask: “What is the input? When will we identify missing values? How could we check the output?”
Student does: Write a 3–4-step algorithm and explain R as the language and RStudio as the working environment.
For a confident student, shorten this block and use the time for the Week 2 bridge at 60–75.
30–4515 min
Write together: vectors, functions and NA
Open “Your first working R program” in Lesson 0 or download the first section of the student starter.R. All observations are fictional.
- Have the student type
scores <- c(12, 10, 14, NA, 9). - For
length(scores), mean(scores) and mean(scores, na.rm = TRUE), predict first and then run each line. - Read the parts of
is.na(), ! and sum() together to count valid observations.
Ask: “Is NA zero? What does na.rm = TRUE exclude? Does exclusion explain why data are missing?”
Open: function and argument explanations →
45–5510 min
Connect to UCL Week 1: tables and columns
On the student’s own privately held copy of pr01. Familiarisation (3).r, find the data-frame and column-extraction sections. The original is not uploaded to this site.
Show, then have the student do: Use crime <- USArrests, head(crime), crime$Murder and max(crime$Murder) from the Week 1 code guide.
Ask: “What do a row and a column represent? What does $ select? What question does max() answer?”
If time is short, head() and selecting one column are enough; leave the second maximum for later practice.
55–605 min
Short break
Take five minutes. On return, ask the student to write the first line themselves without prompting.
60–7515 min
Independent student practice
Default route: Let the student control the screen and create this fictional vector in their script:
practice <- c(2, 5, 8, 11)
- Ask them to find its length and mean.
- Ask them to select values above 6 and predict the result first.
- Replace one value with
NA and explain how the mean changes and which rule they chose.
Help ladder: Expected result → actual result → error message → object name and type → one small hint. Allow time for the student to think first.
Alternative for a ready student: In the same 15 minutes, use the Week 2 two-key join. Ask first: “Which two columns match, and what happens to an unmatched row?” If tidyverse is not installed, discuss matches using two small tables instead of spending the lesson on installation.
Reference: Lesson 1 student tasks A–D.
75–849 min
Interpret and debug
Show the five fictional before/after observations in Lesson 0. Ask the student to calculate one person’s change aloud and explain what a missing pretest means. Discuss why two group means and matched individual changes answer different questions.
Ask: “If the posttest mean is higher, can we say the intervention definitely worked? What else or what missing information might matter?”
Open if useful: Statistics Lab Module 0. The goal is one sentence about the limits of an interpretation, not completing an entire statistics module.
84–906 min
Exit ticket and choose homework
Ask for three short answers: (1) What are an object and a function? (2) What do you check when you see NA? (3) Why does one result not establish causality?
Next step: If objects/vectors remain difficult, repeat Lesson 0; if the basic steps are independent, continue Week 1 and then move to Week 2 when appropriate. Keep any performance note in the private instructor record.
Choose only the appropriate homework option below ↓
After the lesson · Choose one homework option
DEFAULT · 15–25 MINFoundations: Lesson 0 starter.R
Use TODO A, C and F in the student starter file: count valid paired changes, find their mean and address the missing-value error. Write one sentence explaining each. Refer to Lesson 0 as needed.
IF READY · 25–35 MINLesson 1 independent homework
If the student can independently use objects, vectors, means and conditional selection, assign the Lesson 1 homework instead of the foundations option. There is no need to assign both full tasks on the same day.
Submission: For the foundations option, ask for the completed .R file and three short explanations; for Assignment 1, ask for the starter.R, reflection.md and checklist.md files specified on its page. Use an agreed private channel before the next lesson. Agree the exact deadline and assessment expectations together.
The old all-materials archive includes a practice package with teacher answers, so do not present it as an answer-free student archive. Do not upload original UCL files or student information publicly.
When to use the other materials
As needed · Statistics Lab and Lessons 1–6
Use Statistics Lab for statistical thinking and R Lab home for other lessons and homework. They are not all expected to be completed today.
Our own teaching plans and synthetic answer keys are now openly accessible through the Instructor Desk. Genuine student performance records and original UCL course files remain outside the public site.