candy_rankings: Candy Power Ranking

Description Usage Format Source Examples

Description

The raw data behind the story "The Ultimate Halloween Candy Power Ranking" https://fivethirtyeight.com/features/the-ultimate-halloween-candy-power-ranking/.

Usage

1

Format

A data frame with 85 rows representing Halloween candy and 13 variables:

competitorname

The name of the Halloween candy.

chocolate

Does it contain chocolate?

fruity

Is it fruit flavored?

caramel

Is there caramel in the candy?

peanutyalmondy

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.

Source

See https://github.com/fivethirtyeight/data/tree/master/candy-power-ranking

Examples

1
2
3
4
5
6
7
8
9
# To convert data frame to tidy data (long) format, run:
library(dplyr)
library(tidyr)
library(stringr)
candy_rankings_tidy <- candy_rankings %>%
  pivot_longer(-c(competitorname, sugarpercent, pricepercent, winpercent), 
     names_to = "characteristics", values_to = "present") %>%
  mutate(present = as.logical(present)) %>%
  arrange(competitorname)

Example output

Some larger datasets need to be installed separately, like senators and
house_district_forecast. To install these, we recommend you install the
fivethirtyeightdata package by running:
install.packages('fivethirtyeightdata', repos =
'https://fivethirtyeightdata.github.io/drat/', type = 'source')

Attaching package:dplyrThe following objects are masked frompackage:stats:

    filter, lag

The following objects are masked frompackage:base:

    intersect, setdiff, setequal, union

fivethirtyeight documentation built on Oct. 7, 2021, 5:09 p.m.