#Read in the ANT data (see ?ANT).
data(ANT)
#Show summaries of the ANT data.
head(ANT)
str(ANT)
summary(ANT)
#Compute some useful statistics per cell.
cell_stats = ddply(
.data = ANT
, .variables = .( sid , group , cue , flanker )
, .fun <- function(x){
#Compute error rate as percent.
error_rate = (1-mean(x$acc))*100
#Compute mean RT (only accurate trials).
mean_rt = mean(x$rt[x$acc==1])
#Compute SD RT (only accurate trials).
sd_rt = sd(x$rt[x$acc==1])
return(c(error_rate=error_rate,mean_rt=mean_rt,sd_rt=sd_rt))
}
)
#Run an ANOVA on the mean_rt data.
mean_rt_anova = ezANOVA(
data = cell_stats
, dv = .(mean_rt)
, sid = .(sid)
, within = .(cue,flanker)
, between = .(group)
)
#Show the ANOVA & assumption tests.
print(mean_rt_anova)
#Plot the main effect of group.
group_plot = ezPlot(
data = cell_stats
, dv = .(mean_rt)
, sid = .(sid)
, between = .(group)
, x = .(group)
, do_lines = FALSE
, x_lab = 'Group'
, y_lab = 'RT (ms)'
)
#Show the plot.
print(group_plot)
#Plot the cue*flanker interaction.
cue_by_flanker_plot = ezPlot(
data = cell_stats
, dv = .(mean_rt)
, sid = .(sid)
, within = .(cue,flanker)
, x = .(flanker)
, split = .(cue)
, x_lab = 'Flanker'
, y_lab = 'RT (ms)'
, split_lab = 'Cue'
)
#Show the plot.
print(cue_by_flanker_plot)
#Plot the group*cue*flanker interaction.
group_by_cue_by_flanker_plot = ezPlot(
data = cell_stats
, dv = .(mean_rt)
, sid = .(sid)
, within = .(cue,flanker)
, between = .(group)
, x = .(flanker)
, split = .(cue)
, col = .(group)
, x_lab = 'Flanker'
, y_lab = 'RT (ms)'
, split_lab = 'Cue'
)
#Show the plot.
print(group_by_cue_by_flanker_plot)
Run the code above in your browser using DataLab