Consider this dataframe:
data <- data.frame(ID = rep(1, 6),
Loc = c("A","B","D","A","D","B"),
TimeDiff = c(NA, 4.5,2.2,2.1,3.4,7.2))
We have the same ID with observations at multiple locations (Loc). The observations are arranged in the order in which they occurred, so the first observation was at Loc == A, the second was at Loc == B, and so on. TimeDiff is the time period between each consecutive observation. I made the following plot to show the "path" between the Locs over time:
library(tidyverse)
data%>%
mutate(RowNumber = row_number(), xend = lead(Loc), yend = lead(RowNumber))%>%
ggplot()+
geom_segment(aes(x = Loc, y = RowNumber, xend = xend, yend = yend), arrow = arrow(), size = 2)
My main question: how can we weight the size of each arrow according to the variable TimeDiff, and how can we label each arrow with the respective value for TimeDiff? Meaning the arrow connecting the first 2 observations where Loc == A and Loc == B will be thicker than the arrow that follows because there was a greater TimeDiff (4.2) between the two observations.
A side question:
Notice the 3 levels of Loc include A, B, and D. Assume there is another level C that I want to be included in the plot between B and D. How can this be thrown in there?


