Learn R Programming

Ecfun (version 0.2-2)

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.=
"https://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:

State

name of the state

District

District, e.g, 1st, 2nd, At-Large

PVInum

PVI 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.

PVIchar

PVI 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.

PartyOfRepresentative

Party of the incumbent, either 'Republican' or 'Democratic'

The 'Senate' data.frame includes the following columns:

State

name of the state

PVInum

PVI numeric, as for 'House'

PVIchar

PVI rating in character format, as for 'House'

PartyOfGovernor

Party of the Governor of the state

PartyInSenate

party of the incumbent senators, either 'Republican', Democratic', or 'Both'.

houseBalanceNum

House balance as a number with 0 = 100 percent Democratic, 99.9 = 100 percent Republican, and 500 for the same number of Republicans as Democrats.

houseBalanceChar

Count 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.

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
# NOT RUN {
CookPVI <- readCookPVI()
# }
# NOT RUN {
if(!fda::CRAN()){
CookPVI. <- readCookPVI.()
}
# }

Run the code above in your browser using DataLab