How do I get geom_line to connect my desired points?

36 views Asked by At

I am trying to plot reading time over a string of words, divided into 2 groups based on gender. I am able to create the following plot with the following code:

GA %>%
group_by(Gender) %>%
ggplot()+
aes(x=Word, y=Time, color=Gender)+
geom_point(stat = "summary", fun = "mean")

enter image description here`

I would like to add a geom_line to this image, that connects the points horizontally, with a separate line for each gender. However, when I use the following code, I get this image instead.

GA %>%
group_by(Gender) %>%
ggplot()+
aes(x=Word, y=Time, color=Gender)+
geom_point(stat = "summary", fun = "mean")+
geom_line()

enter image description here`

Can anyone help me figure out what I am doing wrong? Thank you so much in advance. I tried using the "group" aesthetic within aes().

0

There are 0 answers