I am trying to produce a dotplot over two variables (matched, unmatched) over several categories as below. The following code roughly does what I want (using dummy data):
library(lattice)
# Generate dummy data that resembles my real data
dp0 <- data.frame(expand.grid(covariate=c("var1","var2"), semester=1:5,
treatment=LETTERS[1:3]), matched=runif(30),
unmatched=runif(30))
# Plot matched and unmatched (percentages) by several semester-level covariates
# across several treatments (models):
dotplot(semester ~ matched + unmatched | treatment + covariate, data=dp0)
It produces the following:
Column labels A, B, and C are all just fine (not necessary to be replicated across rows nor with horrid peach color, but acceptable as is), but row labels (var2, var1) are intended to be less important than column labels. I envision something that looks like this:
| A | B | C |
var1: | |
.... 1 | x o | o x | ox |
.... 2 | ox | x o | o x |
.... 3 |o x | o x| x o |
.... 4 | x o | x o | o x |
.... 5 | o x | x o | ox |
| | | |
var2:...
I tried to mess with group, for instance, but that does not help. This graph is correct as given only it is misleading in the manner it is displayed (in other words, this is a display issue, not a data issue). What are the concepts I should be searching for to accomplish this? Any thoughts appreciated.
Final graph based on @JPC's answer:
ma <- c("Unmatched", "Matched")
ma <- factor(ma, levels=ma, ordered=TRUE)
ggplot(dp0, aes(y=semester)) + geom_point(aes(x=unmatched, shape=ma[1], color=ma[1])) +
geom_point(aes(x=matched, shape=ma[2], color=ma[2])) + facet_grid(covariate~treatment) +
xlim(-1, 1) + labs(x=NULL,y=NULL) + scale_shape_discrete(name="") +
scale_colour_discrete(name="", guide="legend") + theme(legend.position="bottom")