R – I like it, but it's so difficult… same goes for ggplot2!
It took me an hour to figure this out: I had a plot, arranged as 2 panels by using `facet_grid(. ~ group)`. The factor "group" has 2 levels, so that went fine. But then I wanted to add different text to the 2 panels using the test geom, and it always repeated all text on both panels. The solution was hidden in some advice I managed to google: the text geom needs its own dataframe, yes, but the important thing is that in that dataframe there must also be a factor named "group" with 2 levels. So I created the dataframe like so:
dd = data.frame(group=c("control", "patient"),
lbl=c(paste0("p=", format(pValueCtrl, digits=2)),paste0("p=", format(pValuePtnt, digits=2)))),
and in the ggplot-sequence I added
resulting in the attached figure, which my coauthors found beautiful (as do I :). [I obfuscated the ordinate because the paper is not even submitted yet.]