Description Usage Format Source Examples
The raw data behind the story "The Ultimate Halloween Candy Power Ranking" https://fivethirtyeight.com/features/the-ultimate-halloween-candy-power-ranking/.
1 |
A data frame with 85 rows representing Halloween candy and 13 variables:
The name of the Halloween candy.
Does it contain chocolate?
Is it fruit flavored?
Is there caramel in the candy?
Does it contain peanuts, peanut butter or almonds?
Does it contain nougat?
Does it contain crisped rice, wafers, or a cookie component?
Is it a hard candy?
Is it a candy bar?
Is it one of many candies in a bag or box?
The percentile of sugar it falls under within the data set.
The unit price percentile compared to the rest of the set.
The overall win percentage according to 269,000 matchups.
See https://github.com/fivethirtyeight/data/tree/master/candy-power-ranking
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)
|
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: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.