If I have a data.frame containing the data I want to plot, what is the easiest way to “group” data in the different plots of a facet_wrap (or facet_grid) ?
To make a concrete example, if the data frame is like:
ID | P1 | P2 | P3 | P4 | P5
....(data)....
I would like to have P1,P2,P3 over ID in the first facet, P4 over ID in the second and P5 over ID in the third.
I doubt I made an example that exactly mimics yours, but hopefully you’ll get the point. The trick to ggplot2 graphics is to put your data into long format with
melt(). Then you can create afaceting variable according to how you want to group them. Here’s an example: