0

I'm trying to create a panel of paired boxplots using ggpaired. I have 2 sets of scores from 7 measures across 6 participants. When I use ggpaired to plot just 1 measure I can get it to work with no problem:

p <- ggpaired(data, x = "group", y = "presenting",
              xlab="Class Format",
              ylab="Prevalence",
              main="Presenting",
              line.color = "black", line.size = 0.4)
p

Correctly paired boxplot

I can't get this to work across multiple measures using facet.by:

p <- ggpaired(ibp, x = "group", y = "score",
              line.color = "gray", line.size = 0.4,
              facet.by = "cluster", short.panel.labs = FALSE)
p

Points not pairing

I get the following error code in R: geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?

I'm assuming the issue is how I have the data set up. I can only get the pairing to work with the data set up in the excel sheet on the left. I can only figure out how to do facet with the data set up in the excel sheet on the right.

Data Sheets

Any suggestions on how to organize the data to get both the pairing and facets to work? Thank you!

Z.Lin
  • 28,055
  • 6
  • 54
  • 94

1 Answers1

0

For the "geom_path" Error, it can be fixed by setting variable "id".

For this particular case, add an id to "excel sheet on the left", one id should have one "flipped" and one "traditional". and pivot your data into "excel sheet on the right" for ggpaired function.