I'm trying to make a graph in R: it should be a lineplot with SE bars; x-axis there are 5 treatment levels, y-axis the continuous DV. Also, the data should be separated by years (which I managed to do) but also an additional IV grouping variable (let's call it Q). I think it's best if I do a graph for each grouping variable Q.

Here's my code for the first graph, but I can't figure out who to say it should take one half of the data in one graph, the other in the second. (So Q has 2 levels, 1 and 2).

lineplot.CI(x.factor = treat, response = DV, group=year, data = d.sc, ci.fun= function(x) c(mean(x)-2*se(x), mean(x)+2*se(x)))

Any ideas?

thanks in advance!