Load the height data set and create a vector x
with just the male
heights:
library(dslabs)
data(heights)
x <- heights$height[heights$sex=="Male"]
1. What proportion of the data is between 69 and 72 inches (taller than 69,
but shorter or equal to 72)? Store the result in p1_exact
Hint: use a logical operator and mean
.
2. Suppose all you know about the data is the average and the standard
deviation. Use the normal approximation to estimate the proportion you
just calculated. Hint: start by computing the average and standard
deviation. Then use the pnorm
function to predict the proportions.
Store the result in p1_approx
.
3. Notice that the approximation calculated in question nine is very
close to the exact calculation in the first question. Now perform the
same task for more extreme values. Compare the exact calculation and the
normal approximation for the interval (79,81]. Store the result in p2_exact
and p2_approx
respectively. Note the difference between the two.