Session Ready
Exercise

Survey-weighted histograms

If we want to understand the distribution of nightly sleep for Americans, we should construct a histogram. Let's do that now and see the impact of changing the width of the bins.

Instructions 1/3
undefined XP
  • 1

    Use geom_histogram, to map SleepHrsNight to x and WTMEC4YR, the sampling weights, to weight from NHANESraw. Set binwidth to 1.

    • 2

      Reconstruct the histogram but change binwidth to 0.5. Why are there now gaps in the histogram?

    • 3

      Reconstruct the histogram but change binwidth to 2. How did the shape of the histogram change?