Skip to content
tombeesley  /   PSYC121_2021-22  /  
Clear Command Palette
Tip: Type # to search pull requests
Type ? for help and tips
Tip: Type # to search issues
Type ? for help and tips
Tip: Type # to search discussions
Type ? for help and tips
Tip: Type ! to search projects
Type ? for help and tips
Tip: Type @ to search teams
Type ? for help and tips
Tip: Type @ to search people and organizations
Type ? for help and tips
Tip: Type > to activate command mode
Type ? for help and tips
Tip: Go to your accessibility settings to change your keyboard shortcuts
Type ? for help and tips
Tip: Type author:@me to search your content
Type ? for help and tips
Tip: Type is:pr to filter to pull requests
Type ? for help and tips
Tip: Type is:issue to filter to issues
Type ? for help and tips
Tip: Type is:project to filter to projects
Type ? for help and tips
Tip: Type is:open to filter to open content
Type ? for help and tips
We’ve encountered an error and some results aren't available at this time. Type a new search or try again later.
No results matched your search
Search for issues and pull requests # Search for issues, pull requests, discussions, and projects # Search for organizations, repositories, and users @ Search for projects ! Search for files / Activate command mode > Search your issues, pull requests, and discussions # author:@me Search your issues, pull requests, and discussions # author:@me Filter to pull requests # is:pr Filter to issues # is:issue Filter to discussions # is:discussion Filter to projects # is:project Filter to open issues, pull requests, and discussions # is:open
  • Unwatch 1

    Notifications

    Get push notifications on iOS or Android.
Open in github.dev Open in a new github.dev tab
Permalink
ff15dfed06
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
102 lines (76 sloc) 3.27 KB
Open in github.dev
.
library(tidyverse)
# TASK 1 - data processing
data_w8 <- read_csv("data_stroop.csv")
view(data_w8) # view the data
data_w8 %>%
ggplot() +
geom_density(aes(x = time, fill = condition), alpha = .5) # you need to EDIT this for Q4
# create a new column which is the average time
data_w8 <-
data_w8 %>%
group_by(pID) %>% # for each participant...
mutate(avg_time = mean(time)) # create a new average time from the mean of the time column
view(data_w8) # view the data
# distribution of average times
data_w8 %>%
ggplot() +
geom_histogram(aes(avg_time)) # you need to EDIT this for Q6
# Do we need to filter out outliers?
# hint: you'll probably want to use an OR which is this symbol: |
data_w8_f <-
data_w8 %>%
filter(avg_time > 2 & avg_time < 15) # you need to EDIT this for Q7 - these are suggested values - could vary
# TASK 2 - conducting related samples t-tests
# calculate the means for the 3 levels of the condition IV
data_w8_f %>%
group_by(condition) %>% # you need to EDIT this for Q1
summarise(stroop_mean = mean(time)) # you need to EDIT this for Q1
# filter is used to select two levels of the IV - Q3-5
# COMPARISON 1
stroop_comparison <-
data_w8_f %>%
filter(condition == "compatible" | condition == "incompatible")
# run the t-test comparing the means of these two levels
t.test(data = stroop_comparison, time ~ condition, paired = TRUE)
# COMPARISON 1
stroop_comparison <-
data_w8_f %>%
filter(condition == "compatible" | condition == "control")
# run the t-test comparing the means of these two levels
t.test(data = stroop_comparison, time ~ condition, paired = TRUE)
# COMPARISON 1
stroop_comparison <-
data_w8_f %>%
filter(condition == "incompatible" | condition == "control")
# run the t-test comparing the means of these two levels
t.test(data = stroop_comparison, time ~ condition, paired = TRUE)
# TASK 3 - summarising and visualisation
# calculate the means for the 3 levels of the condition IV
data_w8_summary <-# Notice we are creating/overwriting this object here
data_w8_f %>%
group_by(condition) %>% # you need to EDIT this for Q1
summarise(stroop_mean = mean(time),
stroop_SE = sd(time)/sqrt(n())) # you need to EDIT the sd() for Q1
view(data_w8_summary) # if you've done the above step correctly, you should have different means and SEs for each condition
# let's first plot the means
data_w8_summary %>%
ggplot(aes(x = condition, y = stroop_mean)) + # map variables to x and y for Q3
geom_col(size = 2)
# let's do the same again, but now with error bars
data_w8_summary %>%
ggplot(aes(x = condition, y = stroop_mean)) + # map variables to x and y
geom_col(size = 2) +
geom_errorbar(aes(ymin = stroop_mean - stroop_SE, # edit this for Q5
ymax = stroop_mean + stroop_SE), # edit this for Q5
width = .2)
# adding more colour to the figure!
data_w8_summary %>%
ggplot(aes(x = condition, y = stroop_mean, fill = condition)) + # map variables to x and y
geom_col(size = 1,
colour = "black") +
geom_errorbar(aes(ymin = stroop_mean - stroop_SE, # edit this for Q5
ymax = stroop_mean + stroop_SE), # edit this for Q5
width = .2,
size = 1) +
scale_fill_manual(values = c("gold", "dark green", "dark red")) +
theme_classic()