title: “Example 6” |
output: html_document |
If necessary, install the Mosaic package.
install.packages("mosaic")
Table7 <- read.csv("https://sullystats.github.io/Statistics6e/Data/Chapter3/Table7.csv")
head(Table7,n=4)
## University IQ
## 1 A 136
## 2 A 81
## 3 A 80
## 4 A 85
First, let’s draw a side-by-side histogram of the IQ data by university.
library(mosaic)
mean(IQ ~ University,data=Table7)
## A B
## 100.00 100.01
gf_histogram(~IQ|University,data=Table7,binwidth=10,boundary=60,color='black',fill='skyblue',title="IQ Score by University")
Notice that both universities have the same mean IQ of 100.0. However, based on the histograms, University A appears to have more dispersion.
We will determine the standard deviation of each schools’ IQ score to verify University A has more dispersion.
sd(IQ ~ University,data=Table7)
## A B
## 16.080605 8.357535
The standard deviation for University A is 16.1 and the standard deviation for University B is 8.4. University A has more dispersion in IQ scores.