Plotting a Mixed Model Anova using ggplot

Hello!

I am trying to plot a mixed model on a line graph with standard error bars. Although I am unsure where to start. My goal is to have a single graph with four lines (Male - PCB A, Male - PCB B, Female - PCB A, Female - PCB B). To start I converted my data into a long format then into a data frame that summarized the data (n, sd, se, etc):

EtOH_conSE<- summarySEwithin(EtOHconAll, measurevar = "Intake", withinvars = c("Day", "Sex", "PCB_Treatment"), idvar = "...1", na.rm = TRUE, conf.interval = 0.95)

Then using df, I graphed it using ggplot:

EtOHconMixedTrial_graph <- ggplot(EtOH_conSE, aes(x=Day, y=Intake, group = c(Sex,PCB_Treatment), color = c(Sex, PCB_Treatment))) +
geom_line() +
geom_errorbar(width = 0.1, aes(ymin = Intake-se, ymax=Intake+se)) +
geom_point(shape=20, size=2, fill = "black") +
ylim(-1.5,2) + theme(axis.text.x = element_text(angle = 90)) + Order + ggtitle("EtOH Mass Consumed relative to BW")

Although it gave me:

I am not sure how to go about getting the graph I want if this does not work so I can also take any suggestions! I feel like the error could have been when I tried to combine Sex and PCB, however I dont know what else to do. I want to filter out each combination of Sex and PCB Treatment (as stated previously), so that each grouping is a specific color and place them on a single graph. Is that possible on R? I considered maybe using dplyr and filtering that way but that would give me 4 individual graphs, is there anyway to combine it on one then?

Please help!

Hello, you provided your code but only a screenshot of your data. Most forum users will lack the will and motivation to type that out... its therefore better if you provide a copy and pasteable representation of at least example data. For a guide on efficient ways to do that, please read.
FAQ: How to do a minimal reproducible example ( reprex ) for beginners

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.