Pre-Term Preparation

Welcome to Research Methods. Before term starts, please work through the tasks below. Everything here maps to something you can already do in Python — the goal is to learn the R syntax so we can focus on statistics and research design from Week 1.

Time needed: About 3–4 hours total, spread over a few days.


1. Get set up with Git (30 min)

You’ll use Git throughout this course to save your work, collaborate with your group, and build an audit trail for your report.

That’s it for now. We’ll cover branching and pull requests in Week 5.


2. Learn the basics of R (2–3 hours)

You already know Python, so you don’t need to learn programming from scratch. You need to learn R’s syntax for things you can already do.

What you need to be able to do by Week 1

These are the skills the Week 1 exercises assume. Check yourself against each one:

  • df <- read.csv("my_data.csv")
  • head(df)       # first 6 rows
    names(df)      # column names
    nrow(df)       # number of rows
    str(df)        # structure (types of each column)
  • df$temperature
  • mean(df$temperature)
    sd(df$temperature)
    min(df$temperature)
    max(df$temperature)
    summary(df$temperature)
  • plot(df$year, df$temperature,
         xlab = "Year", ylab = "Temperature (°C)")
  • hist(df$temperature, breaks = 20)
  • result <- 42
    greeting <- "hello"
  • celsius_to_kelvin <- function(temp) {
      temp + 273.15
    }

If you can do all of these, you’re ready. If not, revisit the Primers or R4DS sections above.

Things you do NOT need to know yet

Don’t worry about these — we’ll teach them during the course:

  • ggplot2 (Week 2)
  • dplyr / tidyverse (Week 2 onward)
  • The pipe |> (Week 2 onward)
  • Statistical tests like t.test() or aov() (Weeks 3, 6–7)
  • Git branching and pull requests (Week 5)

3. Quick self-test

Open the R console (either at webr.r-wasm.org in your browser, or in RStudio if you’ve installed it) and try this:

# Create a small data frame
weather <- data.frame(
  month = c("Jan", "Feb", "Mar", "Apr", "May"),
  temp_c = c(3.2, 3.8, 5.9, 8.1, 11.2),
  rain_mm = c(52, 40, 44, 47, 50)
)

# Inspect it
head(weather)
names(weather)

# Summary stats
mean(weather$temp_c)
max(weather$rain_mm)

# Plot
plot(weather$temp_c, weather$rain_mm,
     xlab = "Temperature (°C)",
     ylab = "Rainfall (mm)",
     main = "Durham weather")

If this runs without errors and you understand every line, you’re ready for Week 1.


Troubleshooting

“I can’t install R / RStudio” — You don’t need to for the first few weeks. All exercises run in the browser via WebR. If you want a local install for practice, see posit.co/download/rstudio-desktop.

“I’m confused by <- — Think of it as a left-pointing arrow: the value on the right gets stored in the name on the left. It’s R’s version of Python’s =.

“Why R and not Python?” — R has better built-in tools for the statistical work we’ll do (formula interfaces like t.test(y ~ group), diagnostic plots, ggplot2). You already know Python; learning a second language makes you more versatile. The concepts transfer.

“I’ve forgotten all my Python” — That’s fine. The programming concepts (variables, functions, loops, conditionals) are the same in every language. You’re learning new syntax for ideas you already understand.