Learn R: T-test

Load Packages

Haven

# Check if haven is already installed and if it is, load it.
if (!require(haven)){
  # If it's not intalled, then tell R to install it.
  install.packages("haven", dependencies = TRUE)
  # Once it's installed, tell R to load it.
  library(haven)
}
Loading required package: haven

Tidyverse

if (!require(tidyverse)){
  install.packages("tidyverse", dependencies = TRUE)
  library(tidyverse)
}
Loading required package: tidyverse
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Import data

dataset.spss <- read_sav("Harry Potter Data.sav")

T-test

JASP

One Sample T-Test

One Sample T-Test
  t df p
StartDate 19819.946 121 < .001
EndDate 19797.593 121 < .001
Progress 27.159 121 < .001
Duration_in_seconds 2.657 121 0.009
RecordedDate 19694.097 121 < .001
Note.  For the Student t-test, the alternative hypothesis specifies that the mean is different from 0.
Note.  Student's t-test.
</body>