March 2018
Beginner to intermediate
570 pages
13h 42m
English
Refer all the way back to Chapter 5, Using Data to Reason About the World. Remember when we created a mock population of women's heights in the US, and we repeatedly took 10,000 samples of 40 from it to demonstrate the sampling distribution of the sample means? In a code comment, I mentioned in passing that the snippet numeric(10000) created an empty vector of 10,000 elements, but I never explained why we did that. Why didn't we just create a vector of 1, and continually tack on each new sample mean to the end of it? This is demonstrated as follows:
set.seed(1) all.us.women <- rnorm(10000, mean=65, sd=3.5) means.of.our.samples.bad <- c(1) # I'm increasing the number of # samples to 30,000 to prove a point for(i in 1:30000){ ...