I'm trying to create a scatterplot matrix where the x and y variables of the matrix are different (as opposed to pairs()
which use the same variables for both x and y axes).
Currently I'm using pairs2()
function from the TeachingDemos library, but would like to have more control to its appearance and am thinking of replicating it using ggplot2. Is there something equivalent in ggplot2? Or how best should I produce a similar scatterplot matrix if I don't want to use the pairs2()
function?
Not sure if I need to post sample code, here it is anyway
library(TeachingDemos)
a <- matrix(runif(1:10), ncol = 2)
b <- matrix(sample(1:10), ncol = 2)
pairs2(a,b)
Edit:
to clarify, a and b are both matrixes of 2 different variables each. May be clearer with the following sample code instead
library(TeachingDemos)
a <- matrix(runif(1:10), ncol = 2)
b <- matrix(sample(1:10), ncol = 2)
colnames(a) <- c("Ratio of correct answer", "Ratio of time spent")
colnames(b) <- c("Hours spent per study session", "Frequency of study per week")
pairs2(a,b)
Thanks Henrik for the suggestion. Apologies on uncear descriptions, a learning noob here, all suggestions welcome.