Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rudeboybert/fivethirtyeight

R package of data and code behind the stories and interactives at FiveThirtyEight
https://github.com/rudeboybert/fivethirtyeight

cran data-science datajournalism fivethirtyeight r rpackage statistics

Last synced: 6 days ago
JSON representation

R package of data and code behind the stories and interactives at FiveThirtyEight

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
library(fivethirtyeight)
library(dplyr)
```

# fivethirtyeight

[![R-CMD-check](https://github.com/rudeboybert/fivethirtyeight/workflows/R-CMD-check/badge.svg)](https://github.com/rudeboybert/fivethirtyeight/actions)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/fivethirtyeight)](https://cran.r-project.org/package=fivethirtyeight)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/fivethirtyeight)](https://www.r-pkg.org/pkg/fivethirtyeight)

An R package that provides access to the code and data sets published by FiveThirtyEight . Note that while we received guidance from editors at 538, this package is not officially published by 538.

## Installation

Get the latest released version from CRAN:

```{r, eval = FALSE}
install.packages("fivethirtyeight")
```

Or the development version from GitHub:

```{r, eval = FALSE}
# If you haven't installed the remotes package yet, do so:
# install.packages("remotes")
remotes::install_github("rudeboybert/fivethirtyeight", build_vignettes = TRUE)
```

## Usage

All data in the `fivethirtyeight` package are lazy-loaded, so you can access
any dataset without running `data()`:

```{r, eval = FALSE}
library(fivethirtyeight)

head(bechdel)
?bechdel

# If using RStudio:
View(bechdel)
```

To see a detailed list of all `r nrow(data(package = "fivethirtyeight")[[3]]) - 1` datasets, including information on the corresponding articles published on FiveThirtyEight.com, click [here](https://fivethirtyeight-r.netlify.com/articles/fivethirtyeight.html).

## Add-on Package

```{r, echo=FALSE}
all_fivethirtyeightdata_datasets <- data(package = "fivethirtyeightdata")[["results"]] %>%
as_tibble() %>%
pull(Item) %>%
sort()
```

There are also `r all_fivethirtyeightdata_datasets %>% length()` datasets that could not be included in `fivethirtyeight` due to CRAN package size restrictions:

```{r, message=FALSE, warning=FALSE, echo=FALSE}
all_fivethirtyeightdata_datasets
```

These `r all_fivethirtyeightdata_datasets %>% length()` datasets are included in the `fivethirtyeightdata` add-on package, which you can install by running:

```{r, eval=FALSE}
install.packages('fivethirtyeightdata', repos = 'https://fivethirtyeightdata.github.io/drat/', type = 'source')
```

So for example, to load the `senators` dataset, run:

```{r, eval = FALSE}
library(fivethirtyeight)
library(fivethirtyeightdata)
senators
```

## Article in "Technology Innovations in Statistics Education"

The `fivethirtyeight` package was featured in [The fivethirtyeight R Package: "Tame Data" Principles for Introductory Statistics and Data Science Courses](https://escholarship.org/uc/item/0rx1231m) by Kim, Ismay, and Chunn (2018) published in Volume 11, Issue 1 of the journal "Technology Innovations in Statistics Education".

**Abstract**: *As statistics and data science instructors, we often seek to use data in our courses that are rich, real, realistic, and relevant. To this end we created the fivethirtyeight R package of data and code behind the stories and interactives at the data journalism website FiveThirtyEight.com. After a discussion on the conflicting pedagogical goals of "minimizing prerequisites to research" (Cobb 2015) while at the same time presenting students with a realistic view of data as it exists "in the wild," we articulate how a desired balance between these two goals informed the design of the package. The details behind this balance are articulated as our proposed "Tame data principles for introductory statistics and data science courses." Details of the package's construction and example uses are included as well.*

## Data Analysis Examples in Vignettes

For some data sets, there are user-contributed example analyses in the form a package vignette. For example, look at ["Bechdel analysis using the `tidyverse`"](https://fivethirtyeightdata.github.io/fivethirtyeightdata/articles/bechdel.html) based on the `bechdel` dataset used in the article
[The Dollar-And-Cents Case Against Hollywood's Exclusion of
Women](https://fivethirtyeight.com/features/the-dollar-and-cents-case-against-hollywoods-exclusion-of-women). For a complete list of vignettes run

```{r, eval = FALSE}
vignette("user_contributed_vignettes", package = "fivethirtyeightdata")
```

## More Information

* [Andrew Flowers](https://www.linkedin.com/in/andrew-flowers-1319934/) gave a great demonstration of the package and the `bechdel` vignette during his rstudio::conf talk in Orlando, Florida in January 2017. The video of his talk is available [here](https://rstudio.com/resources/rstudioconf-2017/finding-and-telling-stories-with-r/).
* Click this [Google Sheet](https://docs.google.com/spreadsheets/d/1IMWAHNPIDzplafWW6AGnGyHmB1BMjohEw_V5HmT70Gs/edit#gid=840984416) for a master spreadsheet connecting
1. the original 538 data on [GitHub](https://github.com/fivethirtyeight/data) with
1. the data frames in the package with
1. information on the corresponding article