# input data
dta <- read.table("C:/Users/USER/Desktop/verbalIQ.txt",header=T)
head (dta)
##   school pupil  viq language csize ses
## 1      1 17001 15.0       46    29  23
## 2      1 17002 14.5       45    29  10
## 3      1 17003  9.5       33    29  15
## 4      1 17004 11.0       46    29  23
## 5      1 17005  8.0       20    29  10
## 6      1 17006  9.5       30    29  10
# plot 131 school-level regression lines of language score against verbal IQ
library(tidyverse)
## -- Attaching packages ---------------- tidyverse 1.3.0 --
## √ ggplot2 3.3.2     √ purrr   0.3.4
## √ tibble  3.0.3     √ dplyr   1.0.2
## √ tidyr   1.1.2     √ stringr 1.4.0
## √ readr   1.3.1     √ forcats 0.5.0
## -- Conflicts ------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
ggplot(data=dta, aes(x=viq, y=language, group = school)) +
  stat_smooth(method="lm", 
              formula= y ~ x,
              se=F, 
              color="black", 
              linetype=2, 
              size=rel(.5)) +
  labs(x="Verbal IQ", 
       y="language") +
  theme_bw()

#