[1] "Created: Wed Apr  1 16:45:08 2015"

See the introduction for an overview.

library(lme4)
library(ggplot2)
options(digits=5,show.signif.stars=FALSE)

Load in and summarize the data:

data(jsp, package="faraway")
jspr <- jsp[jsp$year==2,]
mjspr <- data.frame(rbind(jspr[,1:6],jspr[,1:6]),subject=factor(rep(c("english","math"),c(953,953))),score=c(jspr$english/100,jspr$math/40))
summary(mjspr)
     school     class     gender        social        raven     
 48     : 126   1:1134   boy :916   4      :738   Min.   : 4.0  
 33     :  88   2: 584   girl:990   9      :276   1st Qu.:22.0  
 42     :  82   3: 108              2      :252   Median :26.0  
 31     :  70   4:  80              5      :170   Mean   :25.3  
 47     :  66                       3      :160   3rd Qu.:30.0  
 21     :  56                       6      :116   Max.   :36.0  
 (Other):1418                       (Other):194                 
       id          subject        score      
 1      :   2   english:953   Min.   :0.000  
 3      :   2   math   :953   1st Qu.:0.390  
 4      :   2                 Median :0.625  
 6      :   2                 Mean   :0.594  
 7      :   2                 3rd Qu.:0.825  
 8      :   2                 Max.   :1.000  
 (Other):1894                                

Plot the data

ggplot(mjspr, aes(x=raven, y=score))+geom_jitter(alpha=0.25)+facet_grid(gender ~ subject)