-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclaylists_reports.qmd
208 lines (170 loc) · 5.14 KB
/
claylists_reports.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
title: "Playlist Summary for 'Wake and Bake' on WFMU"
author: "Art Steinmetz"
date: "January 2025"
# format: html
format:
# typst:
# toc: true
# df-print: "paged"
html:
toc: true
df-print: "paged"
execute:
echo: false
message: false
warning: false
# keep-md: false
---
```{r setup, include=FALSE}
library(tidyverse)
library(ggplot2)
library(ggthemes)
library(lubridate)
library(xts)
library(knitr)
library(remotes)
library(gt)
library(duckdb)
library(duckplyr)
# use duckplyr to load playlists
playlists <- duckplyr_df_from_parquet("data/playlists.parquet")
#playlists <- read_parquet("data/playlists.parquet")
claylists <- playlists %>%
filter(DJ=="WA") %>%
mutate(artist_song = paste(ArtistToken,Title,sep=" - "))
# write_csv(claylists,"claylists.csv")
# claylists |> df_to_parquet("claylists.parquet")
# claylists <- ungroup(claylists)
claylists <- claylists %>%
# limit to whole months
filter(AirDate<floor_date(Sys.Date(),unit="months")) %>%
mutate(year_month=as.yearmon(AirDate))
```
\newpage
# Top 10 Songs By Month for Wake and Bake Last 6 Months
Warning: Ties below bottom of table are discarded.
```{r top songs by month}
#| layout-ncol: 3
#| layout-nrow: 3
month_list <- claylists %>%
#limit top songs to last 12 months
filter(AirDate > Sys.Date() - 365) %>%
# group_by(year_month, artist_song) %>%
summarise(.by = c(year_month, artist_song),song_count = n()) |>
slice_max(by = year_month,
order_by = song_count,
n = 10,
with_ties = FALSE) |>
group_split(year_month)
used_months <- 1:12 |>
map_dbl(\(x) pluck(month_list,x,1,1)) |>
as.yearmon()
names(month_list) <- used_months
print_month_table <- function(month_table) {
month_table |>
gt::gt(groupname_col = "year_month") %>%
# gt set column widths
tab_options(table.font.size = px(10),
row_group.font.weight = "bold",
data_row.padding = px(1),
column_labels.font.weight = "bold") |>
# tab_header("Top Songs By Month for Wake and Bake, Last 12 Months") %>%
cols_merge(c(artist_song, song_count), pattern = "{1} - {2}") %>%
cols_label(artist_song = md("**Artist - Song - Play Count**"))
}
# month_list[10:12] |> walk(print_month_table)
print_month_table(month_list[[10]])
print_month_table(month_list[[11]])
print_month_table(month_list[[12]])
print_month_table(month_list[[7]])
print_month_table(month_list[[8]])
print_month_table(month_list[[9]])
```
\newpage
# Top Artists By Month for Wake and Bake Last 6 months
Warning: Ties below bottom of table are discarded.
```{r top artists by month}
#| layout-ncol: 3
#| layout-nrow: 3
month_list <- claylists %>%
#limit top songs to last 12 months
filter(AirDate > Sys.Date()-365) %>%
# group_by(year_month,Artist) %>%
summarise(.by= c(year_month,Artist),artist_count=n()) %>%
slice_max(by = year_month,
order_by = artist_count,
n = 10,
with_ties = FALSE) |>
group_split(year_month)
print_month_table <- function(month_table) {
month_table |>
gt::gt(groupname_col = "year_month") %>%
# gt set column widths
tab_options(table.font.size = px(10),
data_row.padding = px(1),
row_group.font.weight = "bold",
column_labels.font.weight = "bold") |>
cols_merge(c(Artist, artist_count), pattern = "{1} - {2}") %>%
cols_label(Artist = md("**Artist - Play Count**")) %>%
tab_style(style = list(
cell_text(weight = "bold", style = "italic")
),
locations = cells_row_groups())
}
# month_list[10:12] |> walk(print_month_table)
print_month_table(month_list[[10]])
print_month_table(month_list[[11]])
print_month_table(month_list[[12]])
print_month_table(month_list[[7]])
print_month_table(month_list[[8]])
print_month_table(month_list[[9]])
```
\newpage
# Top 40 Songs of All Time for Wake and Bake
```{r all-time songs}
#| layout-ncol: 2
all_time <- claylists %>%
summarise(.by = c(artist_song), song_count = n()) %>%
slice_max(song_count, n = 40)
panel_1 <- all_time[1:20,]
panel_2 <- all_time[21:nrow(all_time),]
print_all_time <- function(panel){
panel %>%
gt::gt() %>%
tab_options(
table.font.size = px(10),
row_group.font.weight = "bold",
column_labels.font.weight = "bold",
data_row.padding = px(1)
) |>
cols_merge(c(artist_song, song_count), pattern = "{1} - {2}") %>%
cols_label(artist_song = md("**Artist - Song - Play Count**"))
}
print_all_time(panel_1)
print_all_time(panel_2)
```
\newpage
# Top 40 Artists of All Time for Wake and Bake
```{r all-time artists}
#| layout-ncol: 2
all_time <- claylists %>%
summarise(.by = Artist, artist_count = n()) %>%
slice_max(artist_count, n = 40)
panel_1 <- all_time[1:20,]
panel_2 <- all_time[21:nrow(all_time),]
print_all_time <- function(panel){
panel %>%
gt::gt() %>%
tab_options(
table.font.size = px(10),
row_group.font.weight = "bold",
column_labels.font.weight = "bold",
data_row.padding = px(1)
) |>
cols_merge(c(Artist, artist_count), pattern = "{1} - {2}") %>%
cols_label(Artist = md("**Artist - Play Count**"))
}
print_all_time(panel_1)
print_all_time(panel_2)
```