0

I'm trying to figure out a way to link values for the same ID across 3 categorical vars in X and two groups, facetted or not.

Data:

# A tibble: 84 × 4
   time      id group   var
   <fct>  <int> <fct> <int>
 1 Pre-Tx     1 A        77
 2 Pre-Tx     2 A        96
 3 Pre-Tx     3 P        65
 4 Pre-Tx     4 A        51
 5 Pre-Tx     5 P       103
 6 Pre-Tx     6 P       103
 7 Pre-Tx     7 A        74
 8 Pre-Tx     8 P       104
 9 Pre-Tx     9 P        67
10 Pre-Tx    10 A        64
# … with 74 more rows

All I am able to achieve is to link value within each categorical variable with the following code:

pd <- position_jitterdodge(0.5) #https://stackoverflow.com/questions/39533456/how-to-jitter-both-geom-line-and-geom-point-by-the-same-magnitude
ggplot(df2, aes(x = time, y = var, colour = group))+
  geom_boxplot(size = 1)+
  geom_point(position = pd) +
  geom_line(size=0.3, position = pd, alpha = 0.5) +
  labs(y = "", x = "") +
  facet_grid(cols = vars(group))+
  theme_classic() +
  theme(legend.position = "none")

Best I can do FTM

EDIT: I would like something like the following (with every paired observations linked, obviously): enter image description here Thanks a lot

0 Answers0