library(tidyverse)

# Example - Dragon Population
########################################################################################

dragon_population <- read_csv("http://www.cknuckles.com/statsprogramming/data/dragon_data.csv")
dragon_population

ggplot(dragon_population, mapping = aes(x = wingspan)) +
  geom_histogram(bins=50, color="white")

population_parameters <- dragon_population |>
  summarize(
    population_mean = mean(wingspan),
    population_sd = sd(wingspan),
    N = n()
  )
population_parameters


# Example - Random Sample of 75 Dragons
########################################################################################

set.seed(6)   # Same dragon sample as in the book

dragon_sample <- dragon_population |>
  slice_sample(n = 75)       # random sample of size 75
dragon_sample

ggplot(dragon_sample, mapping = aes(x = wingspan)) +
  geom_histogram(bins=50, color="white") +
  scale_x_continuous(breaks = 4:11)

sample_statistics <- dragon_sample |>
  summarize(
    sample_mean = mean(wingspan),
    sample_sd =  sd(wingspan),
    n = n()
  )
sample_statistics
