I am unsure how to provide sample data; my data is currently in a .csv file and is very large. I can provide additional information about the data.
I have used the following code to generate boxplots of the mean for my variable Pun with error bars of the standard error of the mean. However, I did not treat subjects as a random effect (each subject had three trials).
I understand how to fit the random effects model thanks to How to fit a random effects model with Subject as random in R? but I am not sure how I can account for that when I plot it. MS is a factor with 2 levels, Harm is a factor with 4 levels.
cdataPun <- ddply(Emotions1, c("MS.f","Harm.f"), summarise,
N=length(Pun),
mean=mean(Pun),
sd=sd(Pun),
se=sd/sqrt(N))
ggplot(cdataPun, aes(x=Harm.f, y=mean, fill=MS.f)) +
geom_bar(position=position_dodge(), stat="identity", colour="black", size=.3) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.2,
position=position_dodge(.9))+
xlab("Harm Level") +
ylab("Punishment Rating") +
scale_fill_hue(name="Mental State",
breaks=c("Blameless","Purposeful"),
labels=c("Blameless","Purposeful")) +
ggtitle("Punishment Ratings by Harm and Mental State") +
scale_y_discrete(breaks=0:10*1) +
theme_bw()