-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasting_charts.qmd
113 lines (92 loc) · 4.37 KB
/
tasting_charts.qmd
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
title: "tasting_charts"
format:
html:
page-layout: full
embed-resources: true
execute:
echo: false
warning: false
---
Coffee connoisseurs or
some may say 'coffee snobs'? Who are they and what are the trends we see
today? Let's find out!
Admittedly, this is a greatly biased sample of coffee enthusiasts most
likely those leaning who watch YouTube.
Roast levels, processing method, region, elevation, variety, all play a role in the coffee tasting experience.
To ensure every participant tasted nearly the exact same coffee profile, coffee pods were shipped flash frozen liquid of concentrated coffee, needing only to add hot water.
```{r}
library(plotly)
library(dplyr)
library(wordcloud)
source("coffee_functions.R")
```
```{r}
# coffee_cupping_tasting = read.csv("data/coffee-flavors_lexicon.csv")
cup_notes = readxl::read_xlsx("data/coffee-flavors_lexicon.xlsx")
df = read.csv("data/GACTT_RESULTS_ANONYMIZED_v2.csv") |> janitor::clean_names()
```
```{r}
#| layout-ncol: 2
coffee_a_words = count_cupping_notes(df$coffee_a_notes, count_min = 20)
coffee_b_words = count_cupping_notes(df$coffee_b_notes, count_min = 20)
coffee_c_words = count_cupping_notes(df$coffee_c_notes, count_min = 20)
coffee_d_words = count_cupping_notes(df$coffee_d_notes, count_min = 20)
# coffee_a_df = prepare_words(coffee_d_words)
# coffee_a = coffee_words_join(coffee_a_df, coffee_cupping_tasting)
# Source: World Coffee Research Sensory Lexicon
# wordcloud(names(coffee_a_words), coffee_a_words, max.words = 50, random.color = FALSE, colors = brewer.pal(6,"Set2"))
#
# coffee_a_words |> prepare_words(color = "#ff3d19") |> coffee_words_join(cup_notes, color = "#e5e5e5") |> coffee_sunburst()
# coffee_b_words |> prepare_words(color = "#ff3d19") |> coffee_words_join(cup_notes, color = "#e5e5e5") |> coffee_sunburst()
# coffee_c_words |> prepare_words() |> coffee_words_join(cup_notes) |> coffee_sunburst()
# coffee_d_words |> prepare_words() |> coffee_words_join(cup_notes) |> coffee_sunburst()
```
##### Caption One
::: h5
[Caption two]{float=right}
:::
```{r}
#| layout-ncol: 2
# changes size, took up much larger space, but did miss fruity word
a = wordcloud2::wordcloud2(coffee_a_words[1:25], fontFamily = "Arial", size = 0.45)
b = wordcloud2::wordcloud2(coffee_b_words[1:25], fontFamily = "Arial", size = 0.45)
c = wordcloud2::wordcloud2(coffee_c_words[1:25], fontFamily = "Arial", size = 0.35)
d = wordcloud2::wordcloud2(coffee_d_words[1:25], fontFamily = "Arial", size = 0.45)
# htmltools::HTML('<iframe src = "/assets/widgets/a.html" width = "100%" height = "200"></iframe>')
# htmltools::HTML('<iframe src = "/assets/widgets/b.html" width = "100%" height = "200"></iframe>')
save_widget(a)
save_widget(b)
save_widget(c)
save_widget(d)
```
```{r}
all_top = purrr::reduce(
list(
coffee_a_words[1:25] |> prepare_words(color = "#ff3d19") |> mutate(coffee = "A"),
coffee_b_words[1:25] |> prepare_words(color = "#ff3d19") |> mutate(coffee = "B"),
coffee_c_words[1:25] |> prepare_words(color = "#ff3d19") |> mutate(coffee = "C"),
coffee_d_words[1:25] |> prepare_words(color = "#ff3d19") |> mutate(coffee = "D")
),
bind_rows
)
# match_colors = tibble::tribble(~ids, ~color2,
# "A D", "#ee3087",
# "A ", "#ff3d19", # A
# "A CD", "#9ecae1",
# "ABC ", "#3fa746", #
# " B ", "#ff6a6d", # B
# " C ", "#cf179e", # C
# " D", "#d3a778", # D
# "ABCD" ,"#899499",
# " BC ", "#abb9dc",
# NA, "#e5e5e5")
all_top = all_top |> tidyr::pivot_wider(names_from = coffee, values_from = coffee ) |> mutate_at(1:6, ~tidyr::replace_na(., replace = " ")) |> mutate(match_coffee = paste0(`A`, `B`, `C`, `D`, sep = ""))
# TODO function should have a color argument
all_top |> coffee_words_join(cup_notes, color = "#e5e5e5") |>
left_join(y = match_colors, by = c("match_coffee" = "ids")) |>
coffee_sunburst(mcolor = ~color2, hover = ~match_coffee)
# One chart
coffee_a_words[1:25] |> prepare_words(color = "#ff3d19") |> coffee_words_join(cup_notes, color = "#e5e5e5") |> coffee_sunburst()
coffee_b_words[1:25] |> prepare_words(color = "#ff3d19") |> coffee_words_join(cup_notes, color = "#e5e5e5") |> coffee_sunburst()
```