# data management and graphics package
library(tidyverse)
## -- Attaching packages ------------------------------------------ tidyverse 1.3.0 --
## √ ggplot2 3.3.0 √ purrr 0.3.3
## √ tibble 2.1.3 √ dplyr 0.8.5
## √ tidyr 1.0.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()
# input data
dta <- read.table("D:/sheu/verbalIQ.txt", h=T)
str(dta)
## 'data.frame': 2287 obs. of 6 variables:
## $ school : int 1 1 1 1 1 1 1 1 1 1 ...
## $ pupil : int 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 ...
## $ viq : num 15 14.5 9.5 11 8 9.5 9.5 13 9.5 11 ...
## $ language: int 46 45 33 46 20 30 30 57 36 36 ...
## $ csize : int 29 29 29 29 29 29 29 29 29 29 ...
## $ ses : int 23 10 15 23 10 10 23 10 13 15 ...
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

##
## Pearson's product-moment correlation
##
## data: dta$viq and dta$language
## t = 36.781, df = 2285, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.5834141 0.6349371
## sample estimates:
## cor
## 0.6098195