Learn R Programming

Ecfun (version 0.1-4)

readCookPVI: Read Cook Partisan Voting Index

Description

Read tables of the Cook Partisan Voting Index and returns a list with components 'House' and 'Senate'. readCookPVI. returns the tables with the names of the current incumbents per readUShouse and readUSsenate; readCookPVI tables do not include the names of the incumbents.

Usage

readCookPVI(url.=
"http://en.wikipedia.org/wiki/Cook_Partisan_Voting_Index")
readCookPVI.(url.=
"http://en.wikipedia.org/wiki/Cook_Partisan_Voting_Index",
      UShouse=readUShouse(), USsenate=readUSsenate(), ...)

Arguments

url.
Universal resource locator to be read and processed to obtain the desired lists.
UShouse, USsenate
data.frames as returned by readUShouse and readUSsenate, respectively.
...
optional arguments passed to readUShouse and readUSsenate.

Value

  • A list with components "House" and "Senate". Each contains a data.frame. The "House" data.frame returned by readCookPVI includes the following columns:
  • Statename of the state
  • DistrictDistrict, e.g, 1st, 2nd, At-Large
  • PVInumPVI as a number ranging from roughly 50 to 150. 100 means that the vote split in that district was within 0.5 percent of the national average. 101 means that it tilts 1 percent (after rounding) to Republican. 98 means that it tilts 1 percent to Democratic; 99 is not used.
  • PVIcharPVI rating in character format. For example, 'D+1' means that the vote tilted 1 percent toward Democratic more than the national average. 'R+1' means that it tilted 1 percent toward Republican.
  • PartyOfRepresentativeParty of the incumbent, either 'Republican' or 'Democratic'
  • The 'Senate' data.frame includes the following columns:
  • Statename of the state
  • PVInumPVI numeric, as for 'House'
  • PVIcharPVI rating in character format, as for 'House'
  • PartyOfGovernorParty of the Governor of the state
  • PartyInSenateparty of the incumbent senators, either 'Republican', Democratic', or 'Both'.
  • houseBalanceNumHouse balance as a number with 0 = 100 percent Democratic, 99.9 = 100 percent Republican, and 500 for the same number of Republicans as Democrats.
  • houseBalanceCharCount by pary in the house delegation for that state, e.g., '6R, 1D' for 6 Republicans and 1 Democrat.
  • readCookPVI. adds to the above the information returned by readUShouse and readUSsenate.

source

https://en.wikipedia.org/wiki/Cook_Partisan_Voting_Index{Wikipedia, "Cook Partisan Voting Index"} http://cookpolitical.com/{The Cook Political Report}

Details

The primary source for these data is the Cook Political Report web site. However, the current URL we have for these data on that web site includes "2012" in the title. If and when the numbers are updated, we would expect that file name to change. To avoid that problem the code is currently set to read from the Wikipedia article on "Cook Partisan Voting Index". The algorithm reads the web site into a list, finds the desired tables on the list, then parses and formats them as desired. Then it merges the results with UShouse and USsenate.

See Also

readUShouse, readUSsenate

Examples

Run this code
CookPVI <- readCookPVI()

if(!fda::CRAN()){
CookPVI. <- readCookPVI.()
}

Run the code above in your browser using DataLab