moderndive (version 0.2.0)

bowl_samples: Sampling from a tub of balls

Description

Counting the number of red balls in 10 samples of size n = 50 balls from https://github.com/moderndive/moderndive/blob/master/data-raw/sampling_bowl.jpeg

Usage

bowl_samples

Arguments

Format

A data frame 10 rows representing different groups of students' samples of size n = 50 and 5 variables

group

Group name

red

Number of red balls sampled

white

Number of white balls sampled

green

Number of green balls sampled

n

Total number of balls samples

Examples

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

# Compute proportion red
bowl_samples <- bowl_samples %>%
  mutate(prop_red = red / n)
  
# Plot sampling distributions
ggplot(bowl_samples, aes(x = prop_red)) +
  geom_histogram(binwidth = 0.05) +
  labs(x = expression(hat(p)), y = "Number of samples", 
  title = "Sampling distribution of p_hat based 10 samples of size n = 50")
# }

Run the code above in your browser using DataCamp Workspace