I have a scatter plot like this:
p<-ggplot(df, aes(x=x,y=y, group = Year, colour=Year, shape =Year)) + geom_point()+ ...
The Year variable i use has four levels: Yr 1, 2, 3, 4.
What i try to do is to show changes across years by adding arrow segments pointing from Yr 1 to Yr 2, from Y2 to Yr 3, and from Yr 3 to Yr 4. So i used something like this to connect points Yr1 and Yr2:
geom_segment(aes(x=x1,y=y1,xend=x2,yend=y2), color = "grey20", arrow=arrow(length=unit(.1,"cm")))+
geom_segment(aes(x=x2,y=y2,xend=x3,yend=y3), color = "grey20", arrow=arrow(length=unit(.1,"cm")))+
geom_segment(aes(x=x3,y=y3,xend=x4,yend=y4), color = "grey20", arrow=arrow(length=unit(.1,"cm")))
The problem is that i have many missing points. So if a person only has data in Yr1 and Yr4, I still want to connect point Yr 1 with Yr 4, but don't know how.
Is there a way to fix this?
Many thanks!
Yue