I would like to plot two separate pairs of points on a ggplot and then connect them by a line. I know I could create two ggplots and then combine them together, but then no line would be connecting them. How would I connect the pair of points?
Here is my example df:
df <- data.frame(id = c(1, 2, 3),
x_at_end = c(4, 5, 6),
y_at_end = c(8, 10, 12),
x_at_start = c(20, 30, 40),
y_at_start = c(40, 60, 80))
I would like to plot x_at_end
and y_at_end
and then draw a line to the point x_at_start
and y_at_start
create based on the id
. Is this possible in ggplot?