library(RCurl)
library(ggplot2)

The Ultimate Halloween Candy Power Ranking

Introduction

The article (https://fivethirtyeight.com/videos/the-ultimate-halloween-candy-power-ranking/) highlights the mission to find the ultimate candy for trick-or-treaters based off aproval ratings from 8,371 different IP Addresses. The article begins their analysis by asking the public to vote on 269,000 randomly generated matchups of their ideal halloween candy. Everything then focuses on the ingredients and type of candy/chocolate in order to find what people enjoy the most!

data_link <- getURL("https://raw.githubusercontent.com/fivethirtyeight/data/master/candy-power-ranking/candy-data.csv")
data <- read.csv(text = data_link)
head(data)

Explanation of data columns

  • chocolate: Does it contain chocolate?
  • fruity: Is it fruit flavored?
  • caramel: Is there caramel in the candy?
  • peanutalmondy: Does it contain peanuts, peanut butter or almonds?
  • nougat: Does it contain nougat?
  • crispedricewafer: Does it contain crisped rice, wafers, or a cookie component?
  • hard: Is it a hard candy?
  • bar: Is it a candy bar?
  • pluribus: Is it one of many candies in a bag or box?
  • sugarpercent: The percentile of sugar it falls under within the data set.
  • pricepercent: The unit price percentile compared to the rest of the set.
  • winpercent: The overall win percentage according to 269,000 matchups.

Data Subset

I personally love chocolate with peanuts or almonds (Reese’s, I’m looking at you), so I wanted to see the general win percentage of the chocolates listed. I additionally changed the color of the bars if they have caramel or not, just to get a general idea of the preferences of the public.

nutty_candy <- subset(data, peanutyalmondy == 1)
nutty_candy
ggplot(nutty_candy, aes(y = competitorname, group = 1)) +
  geom_bar(aes(x = winpercent, fill = caramel), stat = 'identity')

## Conclusion The final findings show that chocolate is a MUST HAVE, especially if it has crispiness and nuttiness. Expansions to this study would include an increased population. The article mentioned that this study was taken online. Demographics / social status might have an effect on candy preferences. A poll found on facebook might have results that vary from a poll on CNN. One of the findings that I can take away from this article is that myself and an overwhelming percentage of people love Reese’s!!!