data(ChestSizes)
# frequency polygon
plot(ChestSizes, type='b')
# barplot
barplot(ChestSizes[,2], ylab="Frequency", xlab="Chest size")
# calculate expected frequencies under normality, chest ~ N(xbar, std)
n_obs <- sum(ChestSizes$count)
xbar <- with(ChestSizes, weighted.mean(chest, count))
std <- with(ChestSizes, sd(rep(chest, count)))
expected <-
with(ChestSizes, diff(pnorm(c(32, chest) + .5, xbar, std)) * sum(count))
Run the code above in your browser using DataLab