Created
September 21, 2020 20:58
-
-
Save WillForan/5fb9fb87000f4de69e165d5f063e4b9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(dplyr) | |
library(tidyr) | |
theme_set(cowplot::theme_cowplot()) | |
eog <- read.csv('eog_cal/eeg_data_20200921.csv') | |
subjData <- | |
eog %>% | |
unite(ld8, LunaID, ScanDate) %>% # remove LunaID and scanDate columns. replace with ld8 | |
mutate_at(vars(matches('Error')), abs) %>% # abs delta columns | |
# made the data long. column meas has calR2, {Position,Displacement}Error, {mgs,vgs}Latency | |
gather(meas, v, -ld8, -Trial, -Delay) %>% | |
filter(!is.na(v)) %>% | |
# group | |
group_by(ld8, meas, Delay) %>% | |
summarise(subj_mean=mean(v), | |
subj_sd=sd(v), | |
subj_n=n(), | |
subj_se=subj_sd/sqrt(subj_n)) | |
groupData <- subjData %>% group_by(meas, Delay) %>% | |
mutate(subj_mean=abs(subj_mean)) %>% | |
summarize(delay_mean=mean(subj_mean), | |
delay_sd=sd(subj_mean), | |
delay_se=delay_sd/n()) | |
groupData %>% | |
mutate(Delay=as.factor(Delay), | |
mtype=gsub("^[A-Z]?[a-z]*"," ", meas)) %>% | |
ggplot() + | |
aes(x=meas, fill=Delay, y=delay_mean) + | |
geom_bar(stat='identity',position='dodge') + | |
geom_errorbar(position='dodge', | |
aes(ymax=delay_mean+delay_se,ymin=delay_mean-delay_se)) + | |
facet_wrap(~mtype, scales="free") |
Author
WillForan
commented
Sep 21, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment