README.md

fivr

This R package contains data from some of FiveThirtyEight's analyses (as of 2017-06-13). For your convenience, it also contains the functions used to collect the data so you that you can have the most up-to-date information.

You can donwload fivr by runnning the code below:

# install.packages("tidyverse")
# install.packages("devtools")
devtools::install_github("ctlente/fivr")

Usage

Currently this package contains the data from 4 analyses:

To access the tables with these data, simply call them by name:

library(tidyverse)
library(fivr)

glimpse(trump_score)
#> Observations: 531
#> Variables: 9
#> $ name             <chr> "Cory Gardner", "Dean Heller", "Ron John...
#> $ chamber          <chr> "Senate", "Senate", "Senate", "Senate", ...
#> $ party            <chr> " R", " R", " R", " R", " R", " R", " R"...
#> $ state            <chr> " CO", " NV", " WI", " FL", " PA", " ME"...
#> $ district         <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ...
#> $ trump_score      <dbl> 0.976, 0.952, 1.000, 1.000, 0.976, 0.881...
#> $ trump_margin     <dbl> -0.049, -0.024, 0.008, 0.012, 0.007, -0....
#> $ predicted_score  <dbl> 0.449, 0.503, 0.577, 0.587, 0.576, 0.491...
#> $ trump_plus_minus <dbl> 0.527, 0.449, 0.423, 0.413, 0.400, 0.390...

glimpse(congress_votes)
#> Observations: 18,253
#> Variables: 7
#> $ name                 <chr> "Cory Gardner", "Cory Gardner", "Cor...
#> $ date                 <chr> "June 13", "May 11", "May 10", "May ...
#> $ measure              <chr> "Opposing the sale of some arms to S...
#> $ trump_position       <chr> "oppose", "support", "support", "sup...
#> $ vote                 <chr> "No", "No", "Yes", "Yes", "Yes", "Ye...
#> $ agreement_likelihood <dbl> 0.273, 0.838, 0.226, 0.897, 0.266, 0...
#> $ plus_minus           <dbl> 0.727, -0.838, 0.774, 0.103, 0.734, ...

glimpse(congress_race)
#> Observations: 38
#> Variables: 10
#> $ dates           <chr> "Jun. 9-11", "Jun. 4-6", "May 31-Jun. 6",...
#> $ pollster        <chr> "Public Policy Polling", "YouGov", "Quinn...
#> $ grade           <chr> " B+", " B", " A-", NA, " B", NA, " B", N...
#> $ sample_size     <dbl> 811, 1288, 1361, 1999, 1266, 1991, 1266, ...
#> $ sample_pop      <chr> "Registered Voters", "Registered Voters",...
#> $ weight          <dbl> 1.16, 0.77, 1.87, 0.51, 0.64, 0.43, 0.58,...
#> $ republican      <dbl> 0.40, 0.37, 0.39, 0.39, 0.33, 0.39, 0.36,...
#> $ democrat        <dbl> 0.50, 0.41, 0.51, 0.42, 0.39, 0.43, 0.38,...
#> $ leader          <chr> "Democrat +10", "Democrat +4", "Democrat ...
#> $ adjusted_leader <chr> "Democrat +10", "Democrat +6", "Democrat ...

glimpse(trump_approval)
#> Observations: 570
#> Variables: 10
#> $ dates               <chr> "Jun. 10-12", "Jun. 10-12", "Jun. 8-1...
#> $ pollster            <chr> "Gallup", "Gallup", "Rasmussen Report...
#> $ grade               <chr> " B-", " B-", " C+", " A-", " A-", " ...
#> $ sample_size         <dbl> 1500, 1500, 1500, 383, 1451, 1451, 15...
#> $ sample_pop          <chr> "All Adults", "All Adults", "Likely V...
#> $ weight              <dbl> 0.94, 0.94, 0.78, 1.07, 2.02, 2.02, 0...
#> $ approve             <dbl> 0.36, 0.36, 0.43, 0.43, 0.40, 0.40, 0...
#> $ disapprove          <dbl> 0.60, 0.60, 0.57, 0.54, 0.56, 0.56, 0...
#> $ adjusted_approve    <dbl> 0.36, 0.37, 0.39, 0.42, 0.38, 0.39, 0...
#> $ adjusted_disapprove <dbl> 0.59, 0.59, 0.56, 0.54, 0.57, 0.56, 0...

And if you want to get the data yoursef, simply run the corresponding get_ function:

library(tidyverse)
library(fivr)

trump_score <- get_trump_score()
congress_votes <- get_congress_votes()
congress_race <- get_congress_race()
trump_approval <- get_trump_approval()


ctlente/cts documentation built on June 19, 2017, 11:22 a.m.