# reinhold & jochen # RTs library(lme4) library(reshape) library(ggplot2) rm(list=ls()) setwd("~/Projects/work/eyelinkTest/Posner2006_2/analysis/R") library(eyetrackR) # source("functions/parseq.R") load("./Posner2006_2.rda") # Select data: not "first MS" ix <- which(d$TYP == "first MS") d <- d[-ix, ] d[] <- lapply(d,function(x) x[drop=TRUE]) d$MN <- relevel(d$TYP, "no MS") levels(d$MN) <- c("0", "1", "2+") ################################# d.mn <- melt(d, id=c("ID", "EXP", "MN", "CV"), measure=c("mn")) cast(d.mn, EXP ~ ., mean) ################################## # Modern LME ################################## # Generate means and figure based on all trials, allow for missing design cells d.rt <- melt(d, id=c("ID", "EXP", "MN", "CV", "mn"), measure=c("rt")) tab0 <- cast(d.rt, EXP + MN ~ CV, function(x) c(M=round(mean(x)), SE= round(sd(x)/sqrt(length(x))), N=length(x))) # ... set up data tab <- cast(d.rt, EXP + MN + CV ~ ., function(x) c(M=round(mean(x)), SE=round(sd(x)/sqrt(length(x))), N=length(x), lower=round(mean(x)-(sd(x)/sqrt(length(x)))), upper=round(mean(x)+(sd(x)/sqrt(length(x)))) )) # names(tab)[[4]] <- "MeanRT" tab # ... plot theme_set(theme_bw()) # old <- theme_update(panel.background = theme_rect(colour = "white")) p <- qplot(MN, MeanRT, data=tab, group=CV, colour = CV, shape=CV, facets = . ~ EXP, xlab="Number of MS", ylab = "Reaction Time [ms]") p + geom_point(size=3) + geom_line(size=1) + geom_errorbar(aes(max=upper, min=lower, width=0.1), size=1) + scale_colour_grey(start=0.0, end=0.4) ggsave(file="figures/rt.MN.CV.EXP.P2.pdf") p <- qplot(CV, MeanRT, data=tab, group=MN, colour = MN, shape=MN, facets = . ~ EXP, xlab="Cue", ylab = "Reaction Time [ms]") p + geom_point(size=3) + geom_line(size=1) + geom_errorbar(aes(max=upper, min=lower, width=0.1), size=1) + scale_colour_grey(start=0.0, end=0.4) ggsave(file="figures/rt.MN.CV.EXP.P2.pdf")