Getting Started with R

Author

Your name here

Published

September 24, 2026

Goals
  1. Load the packages we need
  2. Load a data file

If this document renders without errors, your setup works.

Click Render at the top of this pane to run everything. To run one chunk at a time, click the green arrow at its top right.

Background reading: Experimentology, Appendix C.

(1) Load packages

Run this once, by hand, if you have never installed these. It is set to eval: false so it does not run every time you render.

install.packages(c("tidyverse", "here"))
library(tidyverse)
Warning: package 'ggplot2' was built under R version 4.3.3
library(here)

(2) Load the data

here() builds file paths starting from the top of your project — the folder holding getting-started-with-r.Rproj. That is why you open the project by double-clicking the .Rproj file, and why you never need setwd().

here()
[1] "/Users/brialong/Documents/GitHub/getting-started-with-r"

Paths built this way work on any computer, and keep working if you later move this file into a subfolder.

rt_data <- read_csv(here("data", "example_rt_data.csv"), show_col_types = FALSE)

glimpse(rt_data)
Rows: 48
Columns: 5
$ participant <chr> "s01", "s01", "s02", "s02", "s03", "s03", "s04", "s04", "s…
$ age_group   <chr> "child", "child", "adult", "adult", "child", "child", "adu…
$ condition   <chr> "congruent", "incongruent", "congruent", "incongruent", "c…
$ rt_ms       <dbl> 800, 976, 496, 582, 803, 924, 401, 609, 690, 808, 515, 627…
$ accuracy    <dbl> 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1…

Simulated reaction times from a made-up Stroop-like task: participant, age_group (child/adult), condition (congruent/incongruent), rt_ms, and accuracy (1 = correct).

If you see 48 rows above, you are set up correctly.