moderndive (version 0.2.0)

pennies_sample: A random sample of 40 pennies sampled from the pennies data frame

Description

A dataset of 40 pennies to be treated as a random sample with pennies acting as the population. Data on these pennies were recorded in 2011.

Usage

pennies_sample

Arguments

Format

A data frame of 40 rows representing 40 randomly sampled pennies from pennies and 2 variables

year

Year of minting

age_in_2011

Age in 2011

See Also

pennies

Examples

Run this code
# NOT RUN {
library(dplyr)
library(ggplot2)

# Take 50 different resamples/bootstraps from the original sample
many_bootstraps <- pennies_sample %>%
  rep_sample_n(size = 40, replace = TRUE, reps = 50)
many_bootstraps

# Compute mean year of minting for each bootstrap sample
bootstrap_means <- many_bootstraps %>% 
  group_by(replicate) %>% 
  summarize(mean_year = mean(year))

# Plot sampling distribution
ggplot(bootstrap_means, aes(x = mean_year)) +
  geom_histogram(binwidth = 1, color = "white") +
  labs(x = expression(bar(x)), y = "Number of samples", 
  title = "Bootstrap distribution of x_bar based 50 resamples of size n = 40")
# }

Run the code above in your browser using DataCamp Workspace