I have a data frame like so:
df= data.frame(cond = c(rep('N', 5), rep('Y', 5)),
var1 = rnorm(10),
var2 = rnorm(10),
var3= rnorm(10))
which looks like this:
> df
cond var1 var2 var3
1 N -0.6115370 0.4215755 1.6492281
2 N 0.1588611 -0.9044593 -0.5339298
3 N -1.0643301 0.1991867 0.6987310
4 N -0.8418736 -1.0986175 -0.3845572
5 N 0.3425105 0.2201171 1.2721364
6 Y 0.1737336 -0.7504061 -0.0856138
7 Y 0.9686804 -0.6037347 0.1050365
8 Y 0.1226120 1.1669462 -0.6542081
9 Y -1.0073227 0.3648727 0.6253705
10 Y -0.1099620 0.6722126 -2.2743869
I'd like to accomplish a plot similar to what's shown in the answer to this question: Plot multiple variables on y-axis with the same x-axis using ggplot in r
except I'd like to plot boxplots. Ideally, I'd have multiple panes, one for each "varN" variable, and each pane would be a set of two boxplots, varN ~ condition. This is a bit similar to lattice plot y~x|var. How do I accomplish this with boxplot?
Note: I am aware that I probably need to melt row id and condition, and I tried that, but couldn't quite get it to work.