library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.2
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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
data <- read_csv("/Users/leahkelly/Downloads/DataR (2).csv")
## Rows: 1116 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): participant, group, item, association
## dbl (6): cycle, naming, recognition, SWPA_composite, TALSA_STM, IFG_lesion_v...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
glimpse(data)
## Rows: 1,116
## Columns: 10
## $ participant <chr> "S5-MCB", "S5-MCB", "S5-MCB", "S5-MCB", "S5-MCB", "S…
## $ group <chr> "PWA", "PWA", "PWA", "PWA", "PWA", "PWA", "PWA", "PW…
## $ item <chr> "kipo", "pileno", "sune", "somipa", "rofa", "balute"…
## $ cycle <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2…
## $ naming <dbl> 0, 0, 0, 0, 0, 0, NA, NA, NA, NA, NA, NA, 1, 0, 0, 0…
## $ association <chr> "Correct", "Correct", "Correct", "Correct", "Correct…
## $ recognition <dbl> 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1…
## $ SWPA_composite <dbl> 0.8247, 0.8247, 0.8247, 0.8247, 0.8247, 0.8247, 0.82…
## $ TALSA_STM <dbl> 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.…
## $ IFG_lesion_volume <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
data_clean <- data %>%
mutate(
group = factor(group, levels = c("HC", "PWA")),
cycle = as.factor(cycle)
)
rec_summary <- data_clean %>%
group_by(group, cycle) %>%
summarise(
n = n(),
mean_recognition = mean(recognition, na.rm = TRUE),
sd_recognition = sd(recognition, na.rm = TRUE),
se_recognition = sd_recognition / sqrt(n),
.groups = "drop"
)
ggplot(rec_summary, aes(x = cycle,
y = mean_recognition,
group = group,
linetype = group,
shape = group)) +
geom_line() +
geom_point(size = 3) +
geom_errorbar(aes(ymin = mean_recognition - se_recognition,
ymax = mean_recognition + se_recognition),
width = 0.1) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1),
limits = c(0, 1)) +
labs(
title = "Recognition Accuracy Across Learning Cycles",
subtitle = "Comparing Healthy Controls (HC) and People with Aphasia (PWA)",
x = "Cycle",
y = "Mean recognition accuracy",
linetype = "Group",
shape = "Group"
) +
theme_minimal(base_size = 13)
