Get startedGet started for free

Challenge (1)

To learn a bit more about how sample means and confidence intervals vary from one sample to another: a challenge!

Using R, we're going to recreate many samples using a for loop. Here is the rough outline:

  1. Obtain a random sample.
  2. Calculate the sample's mean and standard deviation.
  3. Use these statistics to calculate a confidence interval.
  4. Repeat steps (1)-(3) 50 times.

But let's start slowly by initializing the objects you'll use to store the means and standard deviations. We'll also store the desired sample size as n.

This exercise is part of the course

Data Analysis and Statistical Inference

View Course

Exercise instructions

  • Initialize samp_mean and samp_sd with 50 NA values. (Use the rep() function.)
  • Set n to 60.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# The ames data frame is already loaded into the workspace

# Initialize samp_mean, samp_sd and n:
samp_mean <- 
samp_sd <- 
n <- 
Edit and Run Code