-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.Rmd
165 lines (131 loc) · 5.24 KB
/
index.Rmd
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
title: "Crane Wine Cellar"
output:
flexdashboard::flex_dashboard:
css: static/style.css
vertical_layout: fill
---
<!--html_preserve-->
<style>
@import url('https://fonts.googleapis.com/css?family=Caveat|Source+Sans+Pro&display=swap');
</style>
<!--/html_preserve-->
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(summarytools)
library(httr)
library(DT)
library(colorspace)
library(vapoRwave)
library(plotly)
```
```{r data}
# usethis::edit_r_environ()
url_list <- sprintf("https://www.cellartracker.com/xlquery.asp?User=%s&Password=%s&Format=csv&Table=List",
Sys.getenv("CELLAR_TRACKER_USER"),
Sys.getenv("CELLAR_TRACKER_PASS"))
url_availability <- sprintf("https://www.cellartracker.com/xlquery.asp?User=%s&Password=%s&Format=csv&Table=Availability",
Sys.getenv("CELLAR_TRACKER_USER"),
Sys.getenv("CELLAR_TRACKER_PASS"))
response_list <- httr::GET(url_list)
response_availability <- httr::GET(url_availability)
wine_cellar <- content(response_list, type = "text/csv", encoding = "ISO-8859-1")
availability <- content(response_availability, type = "text/csv", encoding = "ISO-8859-1")
#wine_cellar <- read_csv("My Cellar.csv", na = c("", "NA", 9999), locale = locale(encoding = "ISO-8859-1"))
#view(dfSummary(wine_cellar))
wine_cellar <-
wine_cellar %>%
unite("RegionCountry", c(Region, Country), sep = ", ")
```
Sidebar {.sidebar}
=======================================================================
<br />
#### A personal wine cellar report
I collect wine on a very casual, almost accidental, basis. Casual in that I buy wine for drinking not for investing; accidental in that sometimes forget what I have stored away. I've made this website as a way for me to get a handle on the latter issue in service of the former.
I use [CellarTracker](https://www.cellartracker.com/) and their mobile app to manage the inventory. All the code to pull the data from the CellarTracker website, make the tables and charts, and build this site use the R programming language, and you can inspect the code in this [GitHub repo](https://github.com/samuelcrane/cellr).
You can find out more about me at personal site, [samuelcrane.com](https://www.samuelcrane.com/).
<div class="signature">Samuel</div>
Wines
=======================================================================
Column {data-width=600}
-----------------------------------------------------------------------
### Consume Range
```{r fig.height=12, fig.width=12}
# Consume Range
wine_cellar %>%
filter(!is.na(EndConsume)) %>%
mutate(Wine = fct_rev(fct_reorder(Wine, EndConsume))) %>%
ggplot() +
geom_segment(aes(x = Wine, xend = Wine, y = BeginConsume, yend=EndConsume), color = "grey") +
geom_point(aes(x = Wine, y = BeginConsume), color = sequential_hcl(5, "Blues 2")[3], size = 2 ) +
geom_point(aes(x = Wine, y = EndConsume), color = sequential_hcl(5, "Blues 2")[1], size = 2 ) +
theme_minimal(base_family = 'Avenir') +
theme(axis.text.y = element_text(size = 10)) +
coord_flip() +
#geom_hline(yintercept = 2020) +
labs(x = "", y = "Consume between")
ggplotly()
```
Column {data-width=400}
-----------------------------------------------------------------------
### Varietal
```{r}
# Inventory by Varietal
wine_cellar %>%
mutate(MasterVarietal = fct_rev(fct_infreq(MasterVarietal))) %>%
ggplot(aes(x = MasterVarietal)) +
#geom_bar(fill = sequential_hcl(1, "Blues 2")) +
geom_bar(fill = vapoRwave:::jazzCup_palette[3]) +
coord_flip() +
theme_minimal(base_family = 'Avenir') +
theme(panel.grid.major.y = element_blank()) +
scale_y_continuous(expand = c(0, 0), breaks = c(1,5,10,15,20)) +
labs(x = "", y = "Wines")
```
### Region
```{r}
# Inventory by Region
wine_cellar %>%
mutate(RegionCountry = fct_rev(fct_infreq(RegionCountry))) %>%
ggplot(aes(x = RegionCountry)) +
#geom_bar(fill = sequential_hcl(1, "Blues 2")) +
geom_bar(fill = vapoRwave:::jazzCup_palette[3]) +
coord_flip() +
theme_minimal(base_family = 'Avenir') +
theme(panel.grid.major.y = element_blank()) +
scale_y_continuous(expand = c(0, 0), breaks = c(1,5,10,15,20)) +
labs(x = "", y = "Wines")
```
Availability {data-orientation=rows}
=======================================================================
Row {data-height=200}
-----------------------------------------------------------------------
### Next 5
```{r}
# Next 5
availability %>%
arrange(desc(Available)) %>%
slice(1:5) %>%
select(Available, Wine, Vintage, MasterVarietal, Producer, Country, Region, CScore, ComBegin, ComEnd) %>%
mutate(Available = round(Available, digits = 3)) %>%
knitr::kable()
```
Row
-----------------------------------------------------------------------
### Unreported Availability
```{r}
# Unreported Availability
availability %>%
filter(is.na(Available)) %>%
select(Available, Wine, Vintage, MasterVarietal, Producer, Country, Region, CScore) %>%
knitr::kable()
```
List {data-orientation=rows}
=======================================================================
Row {data-height=650}
-----------------------------------------------------------------------
### Complete List
```{r}
wine_cellar %>% datatable(class = 'compact row-border nowrap', options = list(pageLength = 20))
```