## Global options
knitr::opts_chunk$set(cache = TRUE)
library(readxl)
library(dplyr)
library(tidyr)
library(gt)
library(ggplot2)
library(ggbeeswarm)

Pre Test

Descriptive Statistics

df_pre_test <- read_excel("~/Desktop/Tohoku_UCL/Pre_test.xlsx") 

df_summary_pre_test <- df_pre_test %>%
  select(id, condition, score) %>%        
  group_by(condition) %>%
  summarise(
    n = n(),                              
    M = mean(score, na.rm = TRUE),        
    SD = sd(score, na.rm = TRUE)          
  )

df_summary_pre_test %>%
  mutate(across(where(is.numeric), round, 2)) %>%   
  gt() %>%
  cols_label(
    condition = "Condition",
    n = "N",
    M = "M",
    SD = "SD"
  )
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `across(where(is.numeric), round, 2)`.
## Caused by warning:
## ! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
## Supply arguments directly to `.fns` through an anonymous function instead.
## 
##   # Previously
##   across(a:b, mean, na.rm = TRUE)
## 
##   # Now
##   across(a:b, \(x) mean(x, na.rm = TRUE))
Condition N M SD
RWL 4 4.5 3.32
Reading 4 3.0 0.82
Viewing 4 5.5 1.73

Score Distribution by Condition

df_mean_pre_test <- df_pre_test %>%
  group_by(condition) %>%
  summarise(mean_score = mean(score, na.rm = TRUE))

ggplot(df_pre_test, aes(x = condition, y = score, fill = condition)) +
  geom_boxplot(outlier.shape = NA) +
  geom_quasirandom(alpha = 0.7, color = "black", width = 0.2) + 
  stat_summary(fun = mean, geom = "point",
               shape = 23, size = 3, fill = "yellow") +
  labs(title = "Score Distribution by Condition",
       x = "Condition", y = "Score") +
  theme_minimal()

Immediate Form Recognition

Descriptive Statistics

df_immediate_form_recognition <- read_excel("~/Desktop/Tohoku_UCL/immediate_form_recognition.xlsx") 

df_summary_immediate_form_recognition <- df_immediate_form_recognition %>%
  select(id, condition, score) %>%        
  group_by(condition) %>%
  summarise(
    n = n(),                              
    M = mean(score, na.rm = TRUE),        
    SD = sd(score, na.rm = TRUE)          
  )

df_summary_immediate_form_recognition %>%
  mutate(across(where(is.numeric), round, 2)) %>%   # 数値を小数2桁に丸める
  gt() %>%
  cols_label(
    condition = "Condition",
    n = "N",
    M = "M",
    SD = "SD"
  )
Condition N M SD
RWL 3 11.33 9.07
Reading 2 17.00 1.41
Viewing 3 13.67 5.13

Score Distribution by Condition

library(ggplot2)
library(ggbeeswarm)

df_mean_immediate_form_recognition <- df_immediate_form_recognition %>%
  group_by(condition) %>%
  summarise(mean_score = mean(score, na.rm = TRUE))

ggplot(df_immediate_form_recognition, aes(x = condition, y = score, fill = condition)) +
  geom_boxplot(outlier.shape = NA) +
  geom_quasirandom(alpha = 0.7, color = "black", width = 0.2) + 
  stat_summary(fun = mean, geom = "point",
               shape = 23, size = 3, fill = "yellow") +
  labs(title = "Score Distribution by Condition",
       x = "Condition", y = "Score") +
  theme_minimal()

Pre_Immediate_Form_Recognition

df_pre_immediate_form_recognition <- read_excel(
  "~/Desktop/Tohoku_UCL/Pre_Immediate_Form_Recognition.xlsx"
)

df_long <- df_pre_immediate_form_recognition %>%
  pivot_longer(
    cols = c(pre_test, immediate_form_recognition),
    names_to = "test_type",
    values_to = "score"
  )

ggplot(df_long, aes(x = test_type, y = score, group = id, color = condition)) +
  geom_line(alpha = 0.7, linewidth = 1.2) +    
  geom_point(size = 3) +
  labs(
    x = "Test Type",
    y = "Score",
    color = "Condition"
  ) +
  scale_x_discrete(
    limits = c("pre_test", "immediate_form_recognition"),
    labels = c(
      "pre_test" = "Pre-Test",
      "immediate_form_recognition" = "Immediate Form Recognition"
    )
  ) +

  scale_color_manual(
    values = c(
      "Reading" = "hotpink",   
      "RWL" = "deepskyblue",       
      "Viewing" = "gold"    
    )
  ) +
  theme_minimal(base_size = 14) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    legend.title = element_text(face = "bold"),
    legend.position = "top"    
  )

Immediate Meaning Recall

Descriptive Statistics

df_immediate_meaning_recall <- read_excel("~/Desktop/Tohoku_UCL/Immediate_Meaning_Recall.xlsx") 

df_summary_immediate_meaning_recall<- df_immediate_meaning_recall %>%
  select(id, condition, score) %>%        
  group_by(condition) %>%
  summarise(
    n = n(),                              
    M = mean(score, na.rm = TRUE),        
    SD = sd(score, na.rm = TRUE)          
  )

df_summary_immediate_meaning_recall %>%
  mutate(across(where(is.numeric), round, 2)) %>%
  gt() %>%
  cols_label(
    condition = "Condition",
    n = "N",
    M = "M",
    SD = "SD"
  )
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `across(where(is.numeric), round, 2)`.
## Caused by warning:
## ! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
## Supply arguments directly to `.fns` through an anonymous function instead.
## 
##   # Previously
##   across(a:b, mean, na.rm = TRUE)
## 
##   # Now
##   across(a:b, \(x) mean(x, na.rm = TRUE))
Condition N M SD
RWL 4 2.00 2.71
Reading 4 2.50 1.29
Viewing 4 4.75 5.56

Score Distribution by Condition

library(ggplot2)
library(ggbeeswarm)

df_mean_immediate_meaning_recall <- df_immediate_meaning_recall %>%
  group_by(condition) %>%
  summarise(mean_score = mean(score, na.rm = TRUE))

ggplot(df_immediate_meaning_recall, aes(x = condition, y = score, fill = condition)) +
  geom_boxplot(outlier.shape = NA) +
  geom_quasirandom(alpha = 0.7, color = "black", width = 0.2) + 
  stat_summary(fun = mean, geom = "point",
               shape = 23, size = 3, fill = "yellow") +
  labs(title = "Score Distribution by Condition",
       x = "Condition", y = "Score") +
  theme_minimal()

Immediate Meaning Recognition

Descriptive Statistics

df_immediate_meaning_recognition <- read_excel("~/Desktop/Tohoku_UCL/Immediate_Meaning_Recognition.xlsx") 

df_summary_immediate_meaning_recognition <- df_immediate_meaning_recognition %>%
  select(id, condition, score) %>%        
  group_by(condition) %>%
  summarise(
    n = n(),                              
    M = mean(score, na.rm = TRUE),        
    SD = sd(score, na.rm = TRUE)          
  )

df_summary_immediate_meaning_recognition %>%
  mutate(across(where(is.numeric), round, 2)) %>%
  gt() %>%
  cols_label(
    condition = "Condition",
    n = "N",
    M = "M",
    SD = "SD"
  )
Condition N M SD
RWL 4 5.50 5.69
Reading 4 6.25 1.71
Veiwing 4 7.25 6.85

Score Distribution by Condition

df_mean_immediate_meaning_recognition <- df_immediate_meaning_recognition %>%
  group_by(condition) %>%
  summarise(mean_score = mean(score, na.rm = TRUE))

ggplot(df_immediate_meaning_recognition, aes(x = condition, y = score, fill = condition)) +
  geom_boxplot(outlier.shape = NA) +
  geom_quasirandom(alpha = 0.7, color = "black", width = 0.2) + 
  stat_summary(fun = mean, geom = "point",
               shape = 23, size = 3, fill = "yellow") +
  labs(title = "Score Distribution by Condition",
       x = "Condition", y = "Score") +
  theme_minimal()