Description Usage Format References Examples
Ratings of almost 1800 bars of chocolate, collected by Brady Brelinski,
Founding Member of the Manhattan Chocolate Society. The data frame cacao
provides the
entire ratings database and the data frame cacao_small
provides a reduced ratings dataset
that holds only ratings for locations Switzerland, Canada, Austria, U.S.A., Belgium, and Peru.
The object cacao_mcmc
provides the result from a rstanarm::stan_glm()
call
[specifically stan_glm(rating ~ location, prior = student_t(3, 0, 1))
]
run on the cacao_small
data frame.
1 2 3 4 5 |
An object of class tbl_df
(inherits from tbl
, data.frame
) with 1795 rows and 9 columns.
Manhattan Chocolate Society, http://flavorsofcacao.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # Examples for full data set
library(tidyverse)
cacao %>%
mutate(location = fct_lump(location, 20)) %>%
mutate(location = fct_relevel(location, "U.S.A.")) -> cacao_lumped
fit <- lm(rating ~ location, data = cacao_lumped)
summary(fit)
cacao_means <- group_by(cacao_lumped, location) %>%
summarize(mean = mean(rating))
ggplot(cacao_lumped, aes(x = reorder(location, rating), y = rating)) +
geom_point(
size = 0.2,
alpha = 1,
position = position_jitter(height = 0.02, width = 0.2)
) +
geom_point(
data = cacao_means,
aes(location, mean),
size = 2,
color = "red"
) +
coord_flip() +
theme_dviz_grid()
# Examples for stan_glm() result
library(emmeans)
library(tidybayes)
library(ggridges)
cacao_mcmc %>%
emmeans( ~ location) %>%
gather_emmeans_draws() %>%
ggplot(aes(.value, reorder(location, .value))) +
geom_density_ridges_gradient(
aes(fill = stat(quantile)),
color = NA,
quantiles = c(0.005, 0.025, 0.1, 0.9, 0.975, 0.995),
calc_ecdf = TRUE,
scale = 0.9,
rel_min_height = 0.005
) +
stat_pointintervalh(.width = c(.8, .95, .99)) +
scale_fill_manual(
name = NULL,
values = c(desaturate(lighten("#0072B2", c(.7, .5, .3, .1, .3, .5, .7)), .5)),
breaks = c(4, 3, 2, 1),
labels = c("80%", "95%", "99%", ">99%")
) +
theme_dviz_hgrid()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.