forked from celevitz/topChef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
801 lines (681 loc) · 36.5 KB
/
README.Rmd
File metadata and controls
801 lines (681 loc) · 36.5 KB
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
---
title: "topChef"
output: github_document
---
```{r, include = FALSE, message=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
warning=FALSE
)
```
## 1. Introduction to topChef
topChef is a collection of data sets detailing events across all seasons of Top Chef US and Top Chef Masters US and one season of Top Chef Canada. It includes Chef information, challenge descriptions, challenge winners, episode information, guest judge names, and reward/prize information.
## 2. Installation
Not yet on CRAN. So please use: *devtools::install.packages("celevitz/topChef")*.
If it's not appearing to be updated, restart your R sessions, install it again, and call it into your library.
```{r InstallPackage , message=FALSE,warning=FALSE}
devtools::install_github("celevitz/topChef")
```
## 3. References & Acknowlegements
Data were collected manually while watching each season of Top Chef. Additional data were collected from <https://en.wikipedia.org/wiki/Top_Chef>. My Top Chef data journey was inspired by <https://topchefstats.com/>.
Huge thanks to <https://github.com/doehm> for all his support!
```{r Library set up, message=FALSE, warning=FALSE,echo=FALSE,eval=TRUE}
library(topChef)
library(tidyr)
library(dplyr)
```
## 4. Overview of datasets
Across datasets, key joining variables include:
* `chef`
* `szn`
* `sznnumber`
* `series`
* `episode`
### 4.a. Datasets
#### 4.a.i. Chef details
A tibble containing information about Chefs for each season they are in, including placement and gender. For some but not all seasons, there is also information on hometown, current city of residence, age, a flag for whether they are a person of color, and their occupation.
```{r Chef details table , eval=TRUE}
chefdetails
```
#### 4.a.ii. Challenge descriptions
A tibble containing information about each challenge that the Chefs compete in.
```{r Challenge descriptions table , eval=TRUE}
challengedescriptions
```
#### 4.a.iii. Challenge wins
A tibble containing win and loss data for each chef in each episode.
```{r Challenge results table , eval=TRUE}
challengewins
```
#### 4.a.iv. Judges
A tibble containing information about who were the guest judges for each challenge.
```{r Guest Judges table , eval=TRUE}
judges
```
#### 4.a.v. Rewards
A tibble containing information about rewards and prizes won by challenge.
```{r Rewards table , eval=TRUE}
rewards
```
#### 4.a.vi. Episode info
A tibble containing information about each episode.
```{r Episode information table , eval=TRUE}
episodeinfo
```
### 4.b. Example using multiple datasets: How many elimination challenge wins did Top Chef winners have?
##### 4.b.i. Visualization
```{r EliminationWinsForTopChefsVisualization, eval=TRUE,echo=FALSE,message=FALSE}
library(ggplot2)
chefdetails %>%
# Keep just winners and relevant variables (just the winning chef's name)
filter(placement == 1) %>%
select(chef, gender,series,szn) %>%
# Bring on the challenge result data
left_join(challengewins) %>%
# Keep just elimination & sudden death quickfire challenges
filter(challenge_type %in% c("Elimination","Quickfire Elimination","Sudden Death Quickfire")) %>%
# Get the number of wins for each person
group_by(series,szn,sznnumber,chef,gender) %>%
filter(outcome %in% c("WIN","WINNER")) %>%
summarise(wins=n()) %>%
# Plot
ggplot(aes(x=wins,y=chef,color=gender,fill=gender,shape=series)) +
geom_point(size=4) +
theme_minimal() +
# beautification
scale_color_manual(values=c("#1170AA", "#A3ACB9")) +
scale_shape_manual(values=c(0,17,1)) +
scale_x_continuous(name="Number of elimination wins",
breaks=seq(1,9,1),
limits=c(.8,9.5),
labels=seq(1,9,1)) +
theme(panel.grid = element_blank(),
title=element_text(size=12),
axis.line.x=element_line(color="black"),
axis.ticks.x=element_line(color="black"),
axis.text.x=element_text(size=12),
axis.title.x=element_text(size=12)) +
labs(title="Number of elimination wins of Top Chefs"
,caption="I should have ordered by # of wins...")
```
##### 4.b.ii. Code
```{r EliminationWinsForTopChefsCode, eval=FALSE,echo=TRUE,message=FALSE}
library(ggplot2)
chefdetails %>%
# Keep just winners and relevant variables (just the winning chef's name)
filter(placement == 1) %>%
select(chef, gender,series,szn) %>%
# Bring on the challenge result data
left_join(challengewins) %>%
# Keep just elimination & sudden death quickfire challenges
filter(challenge_type %in% c("Elimination","Quickfire Elimination","Sudden Death Quickfire")) %>%
# Get the number of wins for each person
group_by(series,szn,sznnumber,chef,gender) %>%
filter(outcome %in% c("WIN","WINNER")) %>%
summarise(wins=n()) %>%
# Plot
ggplot(aes(x=wins,y=chef,color=gender,fill=gender,shape=series)) +
geom_point(size=4) +
theme_minimal() +
# beautification
scale_color_manual(values=c("#1170AA", "#A3ACB9")) +
scale_shape_manual(values=c(0,17,1)) +
scale_x_continuous(name="Number of elimination wins",
breaks=seq(1,9,1),
limits=c(.8,9.5),
labels=seq(1,9,1)) +
theme(panel.grid = element_blank(),
title=element_text(size=12),
axis.line.x=element_line(color="black"),
axis.ticks.x=element_line(color="black"),
axis.text.x=element_text(size=12),
axis.title.x=element_text(size=12)) +
labs(title="Number of elimination wins of Top Chefs"
,caption="I should have ordered by # of wins...")
```
### 4.c. Example using multiple datasets: winning an episode
#### 4.c.i. Visualization
```{r WonEpisodesViz, eval=TRUE,echo=FALSE,message=FALSE}
library(ggplot2)
library(topChef)
## Won the episode
# Data set up
# how many episodes each chef won in each season
wonepi <- challengewins %>% select(!rating) %>%
mutate(challenge_type=case_when(challenge_type %in% c("Quickfire Elimination","Sudden Death Quickfire") ~ "Quickfire"
,TRUE ~ challenge_type)) %>%
filter(outcome %in% c("WIN","WINNER") & challenge_type %in% c("Elimination","Quickfire")) %>%
distinct() %>%
pivot_wider(names_from=challenge_type,values_from=outcome) %>%
filter(Quickfire == "WIN" & (Elimination %in% c("WIN","WINNER"))) %>%
# were there multiple winners
group_by(series,szn,sznnumber, episode) %>%
mutate(nchefs=n()
,chef=ifelse(nchefs > 1,paste0(chef,"*"),chef)) %>%
# how many times did each chef win an episode?
ungroup() %>% group_by(series,szn,sznnumber,chef) %>%
summarise(n=n()) %>%
select(series,szn,sznnumber,chef,n) %>%
distinct() %>%
mutate(sznnumberchar=case_when(sznnumber <= 9 ~paste0("0",as.character(sznnumber))
,TRUE ~as.character(sznnumber)) ) %>%
filter(series == "US")
# visualize
wonepivizdata <- wonepi %>%
# add on placement of chefs, just for those who have won an episode
left_join(topChef::chefdetails %>% select(szn,sznnumber,chef,placement)) %>%
mutate(placement=as.character(case_when(placement > 5 ~ 5
,TRUE ~ placement))
,placement = case_when(placement == "5" ~ "5th or lower"
,placement == "1" ~ "1st"
,placement == "2" ~ "2nd"
,placement == "3" ~ "3rd"
,placement == "4" ~ "4th"
,TRUE ~ placement))
wonepivizdata <- wonepivizdata[order(wonepivizdata$sznnumberchar,wonepivizdata$n,wonepivizdata$chef),]
## Visualization
wonepivizdata %>%
ggplot(aes(x=sznnumberchar,y=n,label=chef,fill=factor(placement))) +
scale_fill_manual(values=c("#141B41","#1170AA","#5fa2ce","#a3cce9","#ababab")) +
geom_col(position="stack",color="white") +
geom_text(size = 1, position = position_stack(vjust=.5),angle=15
,color=case_when(wonepivizdata$placement == "1st"~ "white"
,wonepivizdata$placement == "2nd" ~ "white"
,TRUE ~ "black"
,is.na(wonepivizdata$placement) ~ "black")) +
labs(title="A Chef has won an episode in all but Seasons 1 and 16"
,subtitle="Winning an episode means that one chef won both the Quickfire and Elimination Challenges.\nThis has happened 35 times. Eight Top Chefs won an episode in their season.\n
Brooke is the only one to do it in two different seasons. In all but three seasons, only
one or two chefs won an episode. In seasons four and seven, three chefs won an
episode. In season 11, six chefs won an episode. Stefan and Gregory G. are the only
chefs to have ever won three episodes in one season. Four chefs have won two
episodes in one season: Angelo S., Ed C., Tiffany D., and Brooke W.
* Travis and Carlos won the team quickfire and the paired elimination challenge."
,caption= "Data: github.com/celevitz/topChef /// Twitter@carlylevitz") +
ylab("\n# of times a chef won an episode this season\n") +
xlab("Season") +
theme_minimal() +
theme(panel.grid = element_blank()
,axis.line.x=element_line(color="black")
,axis.ticks.x=element_line(color="black")
,axis.line.y=element_line(color="black")
,axis.ticks.y=element_line(color="black")
,axis.text.x=element_text(color="black")
,axis.text.y=element_text(color="black")
,axis.title.x = element_text(color="black")
,axis.title.y = element_text(color="black") ) +
guides(fill = guide_legend(title = "Placement"))
```
#### 4.c.ii. Code
```{r WonEpisodesViz_Code, eval=FALSE,echo=TRUE,message=FALSE}
library(ggplot2)
library(topChef)
## Won the episode
# Data set up
# how many episodes each chef won in each season
wonepi <- challengewins %>% select(!rating) %>%
mutate(challenge_type=case_when(challenge_type %in% c("Quickfire Elimination","Sudden Death Quickfire") ~ "Quickfire"
,TRUE ~ challenge_type)) %>%
filter(outcome %in% c("WIN","WINNER") & challenge_type %in% c("Elimination","Quickfire")) %>%
distinct() %>%
pivot_wider(names_from=challenge_type,values_from=outcome) %>%
filter(Quickfire == "WIN" & (Elimination %in% c("WIN","WINNER"))) %>%
# were there multiple winners
group_by(series,szn,sznnumber, episode) %>%
mutate(nchefs=n()
,chef=ifelse(nchefs > 1,paste0(chef,"*"),chef)) %>%
# how many times did each chef win an episode?
ungroup() %>% group_by(series,szn,sznnumber,chef) %>%
summarise(n=n()) %>%
select(series,szn,sznnumber,chef,n) %>%
distinct() %>%
mutate(sznnumberchar=case_when(sznnumber <= 9 ~paste0("0",as.character(sznnumber))
,TRUE ~as.character(sznnumber)) ) %>%
filter(series == "US")
# visualize
wonepivizdata <- wonepi %>%
# add on placement of chefs, just for those who have won an episode
left_join(topChef::chefdetails %>% select(szn,sznnumber,chef,placement)) %>%
mutate(placement=as.character(case_when(placement > 5 ~ 5
,TRUE ~ placement))
,placement = case_when(placement == "5" ~ "5th or lower"
,placement == "1" ~ "1st"
,placement == "2" ~ "2nd"
,placement == "3" ~ "3rd"
,placement == "4" ~ "4th"
,TRUE ~ placement))
wonepivizdata <- wonepivizdata[order(wonepivizdata$sznnumberchar,wonepivizdata$n,wonepivizdata$chef),]
## Visualization
wonepivizdata %>%
ggplot(aes(x=sznnumberchar,y=n,label=chef,fill=factor(placement))) +
scale_fill_manual(values=c("#141B41","#1170AA","#5fa2ce","#a3cce9","#ababab")) +
geom_col(position="stack",color="white") +
geom_text(size = 1, position = position_stack(vjust=.5),angle=15
,color=case_when(wonepivizdata$placement == "1st"~ "white"
,wonepivizdata$placement == "2nd" ~ "white"
,TRUE ~ "black"
,is.na(wonepivizdata$placement) ~ "black")) +
labs(title="A Chef has won an episode in all but Seasons 1 and 16"
,subtitle="Winning an episode means that one chef won both the Quickfire and Elimination Challenges.\nThis has happened 35 times. Eight Top Chefs won an episode in their season.\n
Brooke is the only one to do it in two different seasons. In all but three seasons, only
one or two chefs won an episode. In seasons four and seven, three chefs won an
episode. In season 11, six chefs won an episode. Stefan and Gregory G. are the only
chefs to have ever won three episodes in one season. Four chefs have won two
episodes in one season: Angelo S., Ed C., Tiffany D., and Brooke W.
* Travis and Carlos won the team quickfire and the paired elimination challenge."
,caption= "Data: github.com/celevitz/topChef /// Twitter@carlylevitz") +
ylab("\n# of times a chef won an episode this season\n") +
xlab("Season") +
theme_minimal() +
theme(panel.grid = element_blank()
,axis.line.x=element_line(color="black")
,axis.ticks.x=element_line(color="black")
,axis.line.y=element_line(color="black")
,axis.ticks.y=element_line(color="black")
,axis.text.x=element_text(color="black")
,axis.text.y=element_text(color="black")
,axis.title.x = element_text(color="black")
,axis.title.y = element_text(color="black") ) +
guides(fill = guide_legend(title = "Placement"))
```
## 5. Weighted Index Function
I created a weighted index to compare chefs within and across seasons. I am still working on it, but this is how things currently stand: The weighted index is calculated by assigning a certain number of points to different outcomes. For the sake of simplicity, Sudden Death Quickfires and Quickfire Elimination Challenges are counted as Elimination Challenges. The scoring is as follows:
* Elimination win = 7 points
* Elimination high = 3 points
* Elimination low = -3 points
* Eliminated = -7 points
* Quickfire win = 4 points
* Quickfire high = 2 points
* Quickfire low = -2 points
The `weightedindex` function takes the following parameters:
* `series`: US, US Masters, or Canada
* `seasonnumber`: Values between 1 and 20 for Top Chef US; 1 through 5 for US Masters; and 6 for Canada
* `numberofelimchalls`: Number of elimination challenges through which you want to calculate the index. Values between 1 and 20.
* `numberofquickfires`: Number of quickfire challenges through which you want to calculate the index. Values between 1 and 20.
Currently, the function will include more Quickfire challenges than you have specified in the function. It will keep the episodes in each season through the episode with the Nth Elimination Challenge or the Nth Quickfire, whichever is the higher episode. This was a way to hold constant the number of challenges that have occurred so that chefs could be more comparable across seasons.
The `weightedindex` function exports a tibble with the variables of: series, season name, season number, chef, chef's placement, number of elimination challenges wins/highs/lows/outs, number of quickfire challenge wins/highs/lows, and the weighted index score.
### 5.a. Distribution of Weighted Index Scores at the Completion of All Seasons
```{r Viz_DensityPlot_SetUp, eval=TRUE,echo=FALSE,message=FALSE,include=FALSE}
library(topChef)
library(tidyr)
library(dplyr)
library(RColorBrewer)
## Get the index for all seasons, all episodes
allseasons <- weightedindex("US",1,20,20)
for (season in seq(2,20,1)) {
allseasons <- rbind(allseasons,weightedindex("US",season,20,20))
}
# for sorting reasons, have the season be a character
allseasons$seasonnumchar[allseasons$sznnumber <= 9] <-
paste0("0",as.character(allseasons$sznnumber[allseasons$sznnumber <= 9]))
allseasons$seasonnumchar[allseasons$sznnumber > 9] <-
as.character(allseasons$sznnumber[allseasons$sznnumber > 9])
# Standard deviations
standarddevs <-
aggregate(allseasons$indexWeight,by=list(allseasons$szn,allseasons$sznnumber),FUN=sd)
names(standarddevs) <- c("szn","sznnumber","sd")
standarddevs <- standarddevs[order(standarddevs$sd),] %>%
left_join(topChef::chefdetails %>%
filter(placement == 1) %>%
select(szn,sznnumber,chef)) %>%
mutate(y=0
,labeljust=case_when(szn %in% c("Chicago","Los Angeles","Portland","Seattle") ~ 1
,TRUE ~ 0))
```
```{r Viz_DensityPlot, eval=TRUE,echo=FALSE,message=FALSE}
allseasons %>%
ggplot(aes(x=indexWeight,color=szn,fill=szn)) +
geom_density(alpha=.01) +
labs(title="Density Plot of Weighted Index Score for Every Top Chef US Season") +
scale_color_manual(values=c("#A6CEE3", "#1F78B4", "#B2DF8A", "#33A02C"
,"#FB9A99", "#E31A1C", "#FDBF6F", "#FF7F00"
,"#CAB2D6", "#6A3D9A","#FFFF99","#B15928"
,"#1B9E77", "#D95F02" ,"#7570B3" ,"#E7298A"
,"#66A61E", "#E6AB02", "#A6761D", "#666666")) +
scale_fill_manual(values=c("#A6CEE3", "#1F78B4", "#B2DF8A", "#33A02C"
,"#FB9A99", "#E31A1C", "#FDBF6F", "#FF7F00"
,"#CAB2D6", "#6A3D9A","#FFFF99","#B15928"
,"#1B9E77", "#D95F02" ,"#7570B3" ,"#E7298A"
,"#66A61E", "#E6AB02", "#A6761D", "#666666")) +
theme_minimal()+
theme(legend.position="right"
,legend.key.size = unit(.5, 'cm')) +
guides(color=guide_legend(title="Season name")
,fill=guide_legend(title="Season name")) +
ylab("Density") + xlab("Weighted Index Score")
allseasons %>%
ggplot(aes(x=seasonnumchar,y=indexWeight) ) +
geom_boxplot() +
# add horizontal line at 0
geom_rect(aes(xmin=0
,xmax=20
,ymin=-.5
,ymax=0.5)
,fill="#ffbc69") +
theme_minimal() +
labs(title=paste0("Top Chef Weighted Index: Comparing All Completed Seasons")
,subtitle="Box plots show the minimum, first quartile, median, third quartile, and
maximum weighted index scores for each season. Circles indicate outliers.")+
scale_x_discrete(labels=unique(allseasons$szn[order(allseasons$sznnumber)])) +
theme_minimal() +
ylab("Index score") + xlab("") +
theme(panel.grid = element_blank()
,axis.text.x=element_text(angle=90)
)
standarddevs %>%
ggplot(aes(x=sd,y=y,label=szn)) +
geom_hline(yintercept=0, color="darkcyan") +
geom_point(alpha=.3,size=4) +
theme_minimal() +
ylab("") + xlab("Standard deviation of weighted index scores of each season") +
theme(panel.grid = element_blank()
,axis.line.x=element_line(color="black")
,axis.ticks.x=element_line(color="black")
,axis.line.y=element_blank()
,axis.text.y=element_blank()) +
labs(title="Standard deviation of each Top Chef season's weighted index scores"
,subtitle="Lower standard deviations indicate more even distribution of scores in that season") +
geom_text(angle=45,hjust=standarddevs$labeljust) +
scale_x_continuous(lim=c(7.5,23),breaks=seq(8,22,2),labels=seq(8,22,2))
```
### 5.b. Examples that use the `weightedindex` function: full seasons
##### 5.b.i. Visualizations
```{r Viz_FinalIndex_Names_Setup, eval=TRUE,echo=FALSE,message=FALSE,include=FALSE,warning=FALSE}
library(topChef)
library(ggplot2)
library(tidyr)
library(dplyr)
## Get the index for all seasons
allseasons <- weightedindex("US",1,20,20)
for (season in seq(2,20,1)) {
allseasons <- rbind(allseasons,weightedindex("US",season,20,20))
}
```
```{r Viz_FinalIndex_Names, eval=TRUE,echo=FALSE,message=FALSE,warning=FALSE}
## Graph it
# for sorting reasons, have the season be a character
allseasons$seasonnumchar[allseasons$sznnumber <= 9] <-
paste0("0",as.character(allseasons$sznnumber[allseasons$sznnumber <= 9]))
allseasons$seasonnumchar[allseasons$sznnumber > 9] <-
as.character(allseasons$sznnumber[allseasons$sznnumber > 9])
# for sorting reasons, have the placement as a character
allseasons$placementchar[allseasons$placement <= 9] <-
paste0("0",as.character(allseasons$placement[allseasons$placement <= 9]))
allseasons$placementchar[allseasons$placement > 9] <-
as.character(allseasons$placement[allseasons$placement > 9])
# Distribution of scores at the end of the competition/seasons
graphalltitles <- function(dataset) {
dataset %>%
ggplot(aes(x=placement,y=indexWeight,label=chef)) +
facet_wrap(~paste0("Season ",seasonnumchar)) +
geom_hline(yintercept=0,color="#ffbc69")+
geom_text(hjust=0.5,size=2) +
theme_minimal() +
labs(title=paste0("Top Chef Weighted Index Scores at the End of Seasons")
,subtitle="Comparing All Chefs Across All Seasons\n")+
ylab("Index Score") + xlab("Placement") +
scale_y_continuous(lim=c(-25,50)) +
scale_x_continuous(lim=c(0,20),breaks=seq(1,18,2),labels = seq(1,18,2)) +
theme(panel.grid = element_blank()
,axis.text.x=element_text(size=6,color="black")
,axis.text.y=element_text(size=6,color="black")
,axis.ticks=element_line(color="gray15")
,axis.line=element_line(color="gray15")
,strip.background=element_rect(fill="darkcyan")
,strip.text=element_text(color="black"))
}
graphnotitlenocaption <- function(dataset) {
dataset %>%
ggplot(aes(x=placement,y=indexWeight,label=chef)) +
facet_wrap(~paste0("Season ",seasonnumchar)) +
geom_hline(yintercept=0,color="#ffbc69")+
geom_text(hjust=0.5,size=2) +
theme_minimal() +
ylab("Index score") + xlab("Placement") +
scale_y_continuous(lim=c(-25,50)) +
scale_x_continuous(lim=c(0,20),breaks=seq(1,18,2),labels = seq(1,18,2)) +
theme(panel.grid = element_blank()
,axis.text.x=element_text(size=6,color="black")
,axis.text.y=element_text(size=6,color="black")
,axis.ticks=element_line(color="gray15")
,axis.line=element_line(color="gray15")
,strip.background=element_rect(fill="darkcyan")
,strip.text=element_text(color="black"))
}
graphonlycaption <- function(dataset) {
dataset %>%
ggplot(aes(x=placement,y=indexWeight,label=chef)) +
facet_wrap(~paste0("Season ",seasonnumchar)) +
geom_hline(yintercept=0,color="#ffbc69")+
geom_text(hjust=0.5,size=2) +
theme_minimal() +
ylab("Index Score") + xlab("Placement") +
scale_y_continuous(lim=c(-25,50)) +
scale_x_continuous(lim=c(0,20),breaks=seq(1,18,2),labels = seq(1,18,2)) +
theme(panel.grid = element_blank()
,axis.text.x=element_text(size=6,color="black")
,axis.text.y=element_text(size=6,color="black")
,axis.ticks=element_line(color="gray15")
,axis.line=element_line(color="gray15")
,strip.background=element_rect(fill="darkcyan")
,strip.text=element_text(color="black")) +
labs(caption="Scoring: Elimination win = 7 points. Elimination high = 3. Elimination low = -3. Eliminated = -7.\nQuickfire win = 4. Quickfire high = 2. Quickfire low = -2.\nData github.com/celevitz/topChef ||| Twitter @carlylevitz")
}
graphalltitles(allseasons %>%
filter(sznnumber %in% c(1,2,3,4,5,6)) )
graphnotitlenocaption(allseasons %>%
filter(sznnumber %in% c(7,8,9,10,11,12)) )
graphnotitlenocaption(allseasons %>%
filter(sznnumber %in% c(13,14,15,16,17,18)) )
graphonlycaption(allseasons %>%
filter(sznnumber %in% c(19,20)) )
```
##### 5.b.ii. Code
```{r Viz_FinalIndex_Names_Code, eval=FALSE,echo=TRUE,message=FALSE,warning=FALSE}
library(topChef)
library(ggplot2)
library(tidyr)
library(dplyr)
## Get the index for all seasons
allseasons <- weightedindex("US",1,20,20)
for (season in seq(2,20,1)) {
allseasons <- rbind(allseasons,weightedindex("US",season,20,20))
}
## Graph it
# for sorting reasons, have the season be a character
allseasons$seasonnumchar[allseasons$sznnumber <= 9] <-
paste0("0",as.character(allseasons$sznnumber[allseasons$sznnumber <= 9]))
allseasons$seasonnumchar[allseasons$sznnumber > 9] <-
as.character(allseasons$sznnumber[allseasons$sznnumber > 9])
# for sorting reasons, have the placement as a character
allseasons$placementchar[allseasons$placement <= 9] <-
paste0("0",as.character(allseasons$placement[allseasons$placement <= 9]))
allseasons$placementchar[allseasons$placement > 9] <-
as.character(allseasons$placement[allseasons$placement > 9])
# Distribution of scores at the end of the competition/seasons
graphalltitles <- function(dataset) {
dataset %>%
ggplot(aes(x=placement,y=indexWeight,label=chef)) +
facet_wrap(~paste0("Season ",seasonnumchar)) +
geom_hline(yintercept=0,color="#ffbc69")+
geom_text(hjust=0.5,size=2) +
theme_minimal() +
labs(title=paste0("Top Chef Weighted Index Scores at the End of Seasons")
,subtitle="Comparing All Chefs Across All Seasons\n")+
ylab("Index Score") + xlab("Placement") +
scale_y_continuous(lim=c(-25,50)) +
scale_x_continuous(lim=c(0,20),breaks=seq(1,18,2),labels = seq(1,18,2)) +
theme(panel.grid = element_blank()
,axis.text.x=element_text(size=6,color="black")
,axis.text.y=element_text(size=6,color="black")
,axis.ticks=element_line(color="gray15")
,axis.line=element_line(color="gray15")
,strip.background=element_rect(fill="darkcyan")
,strip.text=element_text(color="black"))
}
graphnotitlenocaption <- function(dataset) {
dataset %>%
ggplot(aes(x=placement,y=indexWeight,label=chef)) +
facet_wrap(~paste0("Season ",seasonnumchar)) +
geom_hline(yintercept=0,color="#ffbc69")+
geom_text(hjust=0.5,size=2) +
theme_minimal() +
ylab("Index score") + xlab("Placement") +
scale_y_continuous(lim=c(-25,50)) +
scale_x_continuous(lim=c(0,20),breaks=seq(1,18,2),labels = seq(1,18,2)) +
theme(panel.grid = element_blank()
,axis.text.x=element_text(size=6,color="black")
,axis.text.y=element_text(size=6,color="black")
,axis.ticks=element_line(color="gray15")
,axis.line=element_line(color="gray15")
,strip.background=element_rect(fill="darkcyan")
,strip.text=element_text(color="black"))
}
graphonlycaption <- function(dataset) {
dataset %>%
ggplot(aes(x=placement,y=indexWeight,label=chef)) +
facet_wrap(~paste0("Season ",seasonnumchar)) +
geom_hline(yintercept=0,color="#ffbc69")+
geom_text(hjust=0.5,size=2) +
theme_minimal() +
ylab("Index Score") + xlab("Placement") +
scale_y_continuous(lim=c(-25,50)) +
scale_x_continuous(lim=c(0,20),breaks=seq(1,18,2),labels = seq(1,18,2)) +
theme(panel.grid = element_blank()
,axis.text.x=element_text(size=6,color="black")
,axis.text.y=element_text(size=6,color="black")
,axis.ticks=element_line(color="gray15")
,axis.line=element_line(color="gray15")
,strip.background=element_rect(fill="darkcyan")
,strip.text=element_text(color="black")) +
labs(caption="Scoring: Elimination win = 7 points. Elimination high = 3. Elimination low = -3. Eliminated = -7.\nQuickfire win = 4. Quickfire high = 2. Quickfire low = -2.\nData github.com/celevitz/topChef ||| Twitter @carlylevitz")
}
graphalltitles(allseasons %>%
filter(sznnumber %in% c(1,2,3,4,5,6)) )
graphnotitlenocaption(allseasons %>%
filter(sznnumber %in% c(7,8,9,10,11,12)) )
graphnotitlenocaption(allseasons %>%
filter(sznnumber %in% c(13,14,15,16,17,18)) )
graphonlycaption(allseasons %>%
filter(sznnumber %in% c(19,20)) )
```
### 5.c. Examples that use the `weightedindex` function 10 Elimination Challenges or 7 Quickfires into the season
##### 5.c.i. Visualizations
```{r Viz_IndexAllSeasons_SetUp, eval=TRUE,echo=FALSE,message=FALSE,include=FALSE,warning=FALSE}
library(topChef)
library(ggplot2)
library(tidyr)
library(dplyr)
## Get the index for all seasons
allseasons <- weightedindex("US",1,10,7)
for (season in seq(2,20,1)) {
allseasons <- rbind(allseasons,weightedindex("US",season,10,7))
}
```
The circles represent outliers: Michael in Las Vegas, Richard in All Stars: New York, Paul in Texas, and Kristen in Seattle. The thick bar within the rectangles are the median scores of chefs scores in that season.
```{r Viz_IndexAllSeasons, eval=TRUE,echo=FALSE,message=FALSE,warning=FALSE}
# drop unneeded variables
allseasons <- allseasons[,c("chef","szn","sznnumber","placement","indexWeight")]
## Graph it
# for sorting reasons, have the season be a character
allseasons$seasonnumchar[allseasons$sznnumber <= 9] <-
paste0("0",as.character(allseasons$sznnumber[allseasons$sznnumber <= 9]))
allseasons$seasonnumchar[allseasons$sznnumber > 9] <-
as.character(allseasons$sznnumber[allseasons$sznnumber > 9])
# for sorting reasons, have the placement as a character
allseasons$placementchar[allseasons$placement <= 9] <-
paste0("0",as.character(allseasons$placement[allseasons$placement <= 9]))
allseasons$placementchar[allseasons$placement > 9] <-
as.character(allseasons$placement[allseasons$placement > 9])
# Distribution of scores at this stage of the competition
allseasons %>%
ggplot(aes(x=seasonnumchar,y=indexWeight) ) +
geom_boxplot() +
# add horizontal line at 0
geom_hline(yintercept=0, color="#ffbc69") +
theme_minimal() +
labs(title=paste0("Top Chef Weighted Index: 7 quickfires & 10 elimination challenges\ninto each season")
,subtitle="Comparing All Chefs Across All Seasons\n"
,caption="Scoring: Elimination win = 7 points. Elimination high = 3. Elimination low = -3. Eliminated = -7.\nQuickfire win = 4. Quickfire high = 2. Quickfire low = -2.\nData github.com/celevitz/topChef ||| Twitter @carlylevitz")+
scale_x_discrete(labels=unique(allseasons$szn[order(allseasons$sznnumber)])) +
theme_minimal() +
ylab("Index score") + xlab("") +
theme(panel.grid = element_blank()
,axis.text.x=element_text(angle=90)
)
```
This example shows the index scores for the Top Four chefs in all seasons with the remaining six chefs from Top Chef World All Stars. Ali, Buddha, and Amar thus far have the highest index scores.
```{r Viz_IndexTopFour, eval=TRUE,echo=FALSE,message=FALSE,warning=FALSE}
# Top Four: Distribution of scores at this stage of the competition
allseasons[allseasons$placement <= 4,] %>%
ggplot(aes(x=placement,y=indexWeight,label=chef) ) +
# add horizontal line at 0
geom_hline(yintercept=0, color="#ffbc69") +
geom_text(size=2) +
theme_minimal() +
labs(title=paste0("Top Chef Weighted Index: 7 quickfires & 10 elimination challenges\ninto each season")
,subtitle="Comparing Top Four Chefs Across All Seasons\n"
,caption="Scoring: Elimination win = 7 points. Elimination high = 3. Elimination low = -3. Eliminated = -7.\nQuickfire win = 4. Quickfire high = 2. Quickfire low = -2.\nData github.com/celevitz/topChef ||| Twitter @carlylevitz")+
scale_x_continuous(lim=c(.5,4.5),breaks=c(1,1.5,2,3,4),labels=c("1","Current\nseason","2","3","4")) +
theme_minimal() +
ylab("Index score") + xlab("Placement") +
theme(panel.grid = element_blank()
)
```
##### 5.c.ii. Code
```{r Code_IndexAllSeasons, eval=FALSE,echo=TRUE,message=FALSE,warning=FALSE}
library(topChef)
library(ggplot2)
library(tidyr)
library(dplyr)
## Get the index for all seasons
allseasons <- weightedindex("US",1,10,7)
for (season in seq(2,20,1)) {
allseasons <- rbind(allseasons,weightedindex("US",season,10,7))
}
# drop unneeded variables
allseasons <- allseasons[,c("chef","szn","sznnumber","placement","indexWeight")]
## Graph it
# for sorting reasons, have the season be a character
allseasons$seasonnumchar[allseasons$sznnumber <= 9] <-
paste0("0",as.character(allseasons$sznnumber[allseasons$sznnumber <= 9]))
allseasons$seasonnumchar[allseasons$sznnumber > 9] <-
as.character(allseasons$sznnumber[allseasons$sznnumber > 9])
# for sorting reasons, have the placement as a character
allseasons$placementchar[allseasons$placement <= 9] <-
paste0("0",as.character(allseasons$placement[allseasons$placement <= 9]))
allseasons$placementchar[allseasons$placement > 9] <-
as.character(allseasons$placement[allseasons$placement > 9])
# Distribution of scores at this stage of the competition
allseasons %>%
ggplot(aes(x=seasonnumchar,y=indexWeight) ) +
geom_boxplot() +
# add horizontal line at 0
geom_hline(yintercept=0, color="#ffbc69") +
theme_minimal() +
labs(title=paste0("Top Chef Weighted Index: 7 quickfires & 10 elimination challenges\ninto each season")
,subtitle="Comparing All Chefs Across All Seasons\n"
,caption="Scoring: Elimination win = 7 points. Elimination high = 3. Elimination low = -3. Eliminated = -7.\nQuickfire win = 4. Quickfire high = 2. Quickfire low = -2.\nData github.com/celevitz/topChef ||| Twitter @carlylevitz")+
scale_x_discrete(labels=unique(allseasons$szn[order(allseasons$sznnumber)])) +
theme_minimal() +
ylab("Index score") + xlab("") +
theme(panel.grid = element_blank()
,axis.text.x=element_text(angle=90)
)
# Top Four: Distribution of scores at this stage of the competition
allseasons[allseasons$placement <= 4,] %>%
ggplot(aes(x=placement,y=indexWeight,label=chef) ) +
# add horizontal line at 0
geom_hline(yintercept=0, color="#ffbc69") +
geom_text(size=2) +
theme_minimal() +
labs(title=paste0("Top Chef Weighted Index: 7 quickfires & 10 elimination challenges\ninto each season")
,subtitle="Comparing Top Four Chefs Across All Seasons\n"
,caption="Scoring: Elimination win = 7 points. Elimination high = 3. Elimination low = -3. Eliminated = -7.\nQuickfire win = 4. Quickfire high = 2. Quickfire low = -2.\nData github.com/celevitz/topChef ||| Twitter @carlylevitz")+
scale_x_continuous(lim=c(.5,4.5),breaks=c(1,1.5,2,3,4),labels=c("1","Current\nseason","2","3","4")) +
theme_minimal() +
ylab("Index score") + xlab("Placement") +
theme(panel.grid = element_blank()
)
```