0
votes

I have a dataset with three factors (Group=Between; Drug=Within; Session=Within) and one response variable (DEs2mPre). I am able to plot faceted boxplot using

qplot(Session, DEs2mPre, data = Dummy.Data, colour = Drug, facets=Group~., -geom="boxplot")

I have three groups and two levels of Drug, so I get nice 3X2 graph with 3 individual graphs for each group with two levels of drug over the sessions on each graph. However instead of boxplots I would like to see lines connecting the means on each session. When I change geom to geom="line", I get a mess of lines what looks like a line for every subject in the dataset and not a grouped (mean like) visualization of the data like what you would see with lineplot.CI (sciplot package).

Is there any way to do that in ggplot2?

Sorry I couldn't add my graphs because I do not have enough "reputation points".

Thanks for any help in advance.

1

1 Answers

1
votes

You get a mess of lines since ggplot connects all data points by default. You need to tell ggplot to use the mean of each group instead. The appropriate arguments are stat = "summary" and fun.y = "mean".

qplot(Session, DEs2mPre, data = Dummy.Data, colour = Drug, facets = Group~.,
      stat = "summary", fun.y = "mean", geom = "line")