As is often the case with ggplot2, the hard part is getting the data into the correct form. In this case we want to collapse the two x-variable columns into one, collapse the two y-variable columns into one, and add indicators that denote which x and y variable each value comes from:
library(reshape2)
library(ggplot2)
dat <- data.frame(a, b)
names(dat) <- c("x_1", "x_2", "y_1", "y_2")
dat.m <- melt(dat, measure.vars = c("x_1", "x_2"), variable.name = "x_var", value.name = "x")
dat.m <- melt(dat.m, measure.vars = c("y_1", "y_2"), variable.name = "y_var", value.name = "y")
Now that the data is in the form expected by ggplot2, constructing the actual graphic is easy:
ggplot(dat.m, aes(x=x, y=y)) +
geom_point()+
facet_grid(y_var ~ x_var, scales="free")
EDIT: An updated version corresponding to your new example is
library(reshape2)
library(ggplot2)
dat <- data.frame(a, b, check.names = FALSE)
dat.m <- melt(dat,
measure.vars = colnames(a),
variable.name = "x_var",
value.name = "Ratio")
dat.m <- melt(dat.m,
measure.vars = colnames(b),
variable.name = "y_var",
value.name = "Study")
ggplot(dat.m, aes(x=Ratio, y=Study)) +
geom_point()+
facet_grid(y_var ~ x_var, scales="free")