Load libraries

  library(mosaic)
  library(dplyr)
  library(googledrive)
  library(googlesheets4)

Read in data and rename variables

  sheetnm  <- "https://docs.google.com/spreadsheets/d/1fobwCBlLa-FMrKSVH47egLZ9bwW8wPKigRQ8WytnYq8/edit?usp=sharing"
  sheetnm
[1] "https://docs.google.com/spreadsheets/d/1fobwCBlLa-FMrKSVH47egLZ9bwW8wPKigRQ8WytnYq8/edit?usp=sharing"
  pulse2025<-read_sheet(sheetnm)
✔ Reading from "2025Pulse (Responses)".
✔ Range 'Form Responses 1'.
  names(pulse2025)<-c("Time", "participate", "pulse", "treatment")

Filter out any students that chose not to participate and then select only the Time, pulse and treatment variables

  pulse2025<-filter(pulse2025, participate=="yes")
  pulse2025<-select(pulse2025, c("Time", "pulse", "treatment"))
  tally(~treatment, data=pulse2025)
treatment
Control 
      2 
  gf_boxplot(pulse~treatment, data=pulse2025, main="2025 Data")

Fix up data so can merge with prior years (rename trt groups)

  pulse2025$treatment[pulse2025$treatment=="Control"]<-"control"
  pulse2025$treatment[pulse2025$treatment=="Exercise"]<-"treatment"

Add “year” to the data sets so can combine with past data

  pulse2025$year<-"2025"

Multiply pulse/30 sec by 2 and create trt by year variable

  pulse2025$pulse<-2*pulse2025$pulse
  pulse2025$Treatment<-paste(pulse2025$treatment, pulse2025$year,  sep=":")

Read in data from past years (will need to make sure columns are the same)

  pulse2025<-pulse2025 %>% select("treatment", "pulse", "year", "Treatment")
  pulseall<-read.csv("data/pulseall2024.csv")
  pulseall<-rbind(pulseall, pulse2025)

Drop the data from 2023 as some students took their pulse for 30 seconds and some for 1 minute.

  pulseall <- filter(pulseall, year !="2023")   
  tally(treatment~year, data=pulseall)
           year
treatment   2014 2015 2016 2017 2018 2019 2020 2022 2024 2025
  control     16   20   19   21   16   13   21   23   21    2
  treatment   17   20   12   14   17   15   24   19   17    0

Plots

  gf_density(~pulse|year, fill=~treatment,data=pulseall)

  gf_boxplot(pulse~treatment|year,data=pulseall)

Write out data for lab 3

  write.csv(pulseall, file="data/pulseall2025.csv", row.names = FALSE)