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.
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(), ...)
Universal resource locator to be read and processed to obtain the desired lists.
data.frame
s as returned by
readUShouse
and
readUSsenate
, respectively.
optional arguments passed to
readUShouse
and
readUSsenate
.
A list with components "House" and "Senate".
Each contains a data.frame
. The
"House" data.frame returned by readCookPVI
includes the following columns:
name of the state
District, e.g, 1st, 2nd, At-Large
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.
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.
Party of the incumbent, either 'Republican' or 'Democratic'
The 'Senate' data.frame includes the following columns:
name of the state
PVI numeric, as for 'House'
PVI rating in character format, as for 'House'
Party of the Governor of the state
party of the incumbent senators, either 'Republican', Democratic', or 'Both'.
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.
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.
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
.
# NOT RUN {
CookPVI <- readCookPVI()
# }
# NOT RUN {
if(!fda::CRAN()){
CookPVI. <- readCookPVI.()
}
# }
Run the code above in your browser using DataLab