Sampling in R
Richie Cotton
Data Evangelist at DataCamp


| Year | Average French Age |
|---|---|
| 1975 | 31.6 |
| 1985 | 33.6 |
| 1995 | 36.2 |
| 2005 | 38.9 |
| 2015 | 41.2 |
coffee_ratings %>%
summarize(mean_cup_points = mean(total_cup_points))
mean_cup_points
1 82.09
coffee_ratings_first10 <- coffee_ratings %>%
slice_head(n = 10)
coffee_ratings_first10 %>%
summarize(mean_cup_points = mean(total_cup_points))
mean_cup_points
1 89.1
coffee_ratings %>%
ggplot(aes(x = total_cup_points)) +
geom_histogram(binwidth = 2)

coffee_ratings_first10 %>%
ggplot(aes(x = total_cup_points)) +
geom_histogram(binwidth = 2) +
xlim(59, 91)

coffee_ratings %>%
ggplot(aes(x = total_cup_points)) +
geom_histogram(binwidth = 2)

coffee_ratings %>%
slice_sample(n = 10) %>%
ggplot(aes(x = total_cup_points)) +
geom_histogram(binwidth = 2) +
xlim(59, 91)

Sampling in R