library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
## ✓ tibble  3.1.0     ✓ dplyr   1.0.5
## ✓ tidyr   1.1.1     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(here)
## here() starts at /Users/caoanjie/Desktop/projects/looking_time/adult_analysis
m_rt <- read_csv(here("data/platform_comparison_data/mTurk/processed_data/trimmed_RTdata.csv")) %>% mutate(platform = "mTurk")
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   block_number = col_double(),
##   block_type = col_character(),
##   trial_number = col_double(),
##   item_type = col_character(),
##   trial_type = col_character(),
##   trial_complexity = col_character(),
##   item_id = col_character(),
##   rt = col_double(),
##   exposure_type = col_character(),
##   half = col_character(),
##   block_deviant_number = col_double(),
##   trial_type_index = col_character(),
##   first_dev_position = col_double(),
##   second_dev_position = col_double()
## )
m_demog <- read_csv(here("data/platform_comparison_data/mTurk/processed_data/trimmed_demogdata.csv")) %>% mutate(platform = "mTurk")
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   age = col_double(),
##   ethnicity = col_character(),
##   gender = col_character(),
##   education = col_character()
## )
m_complexity <- read_csv(here("data/platform_comparison_data/mTurk/processed_data/trimmed_complexitydata.csv")) %>% mutate(platform = "mTurk")
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   question_type = col_character(),
##   stimulus = col_character(),
##   rating = col_double()
## )
m_similarity <- read_csv(here("data/platform_comparison_data/mTurk/processed_data/trimmed_similaritydata.csv")) %>% mutate(platform = "mTurk")
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   question_type = col_character(),
##   stimulus_left = col_character(),
##   stimulus_right = col_character(),
##   rating = col_double()
## )
p_rt <- read_csv(here("data/platform_comparison_data/prolific/processed_data/trimmed_RTdata.csv")) %>% mutate(platform = "prolific")
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   block_number = col_double(),
##   block_type = col_character(),
##   trial_number = col_double(),
##   item_type = col_character(),
##   trial_type = col_character(),
##   trial_complexity = col_character(),
##   item_id = col_character(),
##   rt = col_double(),
##   exposure_type = col_character(),
##   half = col_character(),
##   block_deviant_number = col_double(),
##   trial_type_index = col_character(),
##   first_dev_position = col_double(),
##   second_dev_position = col_double()
## )
p_demog <- read_csv(here("data/platform_comparison_data/prolific/processed_data/trimmed_demogdata.csv")) %>% mutate(platform = "prolific")
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   age = col_double(),
##   ethnicity = col_character(),
##   gender = col_character(),
##   education = col_character()
## )
p_complexity <- read_csv(here("data/platform_comparison_data/prolific/processed_data/trimmed_complexitydata.csv")) %>% mutate(platform = "prolific")
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   question_type = col_character(),
##   stimulus = col_character(),
##   rating = col_double()
## )
p_similarity <- read_csv(here("data/platform_comparison_data/prolific/processed_data/trimmed_similaritydata.csv")) %>% mutate(platform = "prolific")
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   question_type = col_character(),
##   stimulus_left = col_character(),
##   stimulus_right = col_character(),
##   rating = col_double()
## )
rt <- bind_rows(m_rt, p_rt) %>% 
  mutate(looking_time = case_when(
    exposure_type == "forced_short" & trial_number == 1 ~ 1000, 
    exposure_type == "forced_long" & trial_number == 1 ~ 10000, 
    TRUE ~ 500 + rt
  ))
demog <- bind_rows(m_demog, p_demog)
complexity <- bind_rows(m_complexity, p_complexity)
similarity <- bind_rows(m_similarity, p_similarity)

basic descriptive

rt %>% 
  group_by(platform) %>% 
  distinct(subject, .keep_all = TRUE) %>% 
  count()
## # A tibble: 2 x 2
## # Groups:   platform [2]
##   platform     n
##   <chr>    <int>
## 1 mTurk       23
## 2 prolific    21
demog %>% 
  ggplot(aes(x = age, fill = platform)) + 
  geom_density(alpha = .5)

rt %>% 
   ggplot(aes(x = rt, fill = platform)) + 
  geom_density(alpha = .3) + 
  scale_x_log10() + 
  facet_wrap(~block_type) + 
  xlab("rt(log)") + 
  labs(title = "reaction time" )

rt %>% 
   ggplot(aes(x = looking_time, fill = platform)) + 
  geom_density(alpha = .3) + 
  scale_x_log10() + 
  facet_wrap(~block_type) + 
  xlab("looking time(log)") + 
  labs(title = "looking time")