Learn R Programming

Ecfun (version 0.2-2)

readUShouse: Read the list of representatives in the United States House of Representatives

Description

Read the list of representatives in the United States House of Representatives.

Usage

readUShouse(url.="http://www.house.gov/representatives/",
   nonvoting=c('American Samoa', 'District of Columbia',
               'Guam', 'Northern Mariana Islands', 'Puerto Rico',
               'Virgin Islands'),
   fixNonStandard=subNonStandardNames, ...)

Arguments

url.

Universal resource locator to be read and processed to obtain the desired list

nonvoting

Character vector of the names of US territories that send a nonvoting delegate to the US House.

fixNonStandard

function to look for and repair nonstandard names such as names containing characters with accent marks that are sometimes mangled by different software. Use identity if this is not desired.

optional arguments passed to fixNonStandard

Value

readUShouse returns a data.frame with row names = District (State + district, like "New York 3rd") and the following columns:

State

A factor identifying the state or territory the person represents

state

A factor giving the 2-letter US Postal Service abbreviation for the state or non-state governmental entity.

district

An integer identifying the district each person represents, with 0 for entities with only one representative, designated "At Large" for states, "Resident Commissioner" for Puerto Rico, and "Delegate" for the territories.

Name

A character vector giving the name of each representative (in "surname, given name" format)

party

a factor identifying the party affiliation of each representative ("D" or "R").

Room

a character vector identifying the room number of the office

Phone

a character vector giving the phone number

Committees

a character vector giving the committee assignments of each representative

surname

a character vector giving the surname of each representative

givenName

a character vector with the given name of each representative (possibly with middle name or initial, a nickname, and a suffix like "Jr.")

Details

1. House.gov <- readHTMLTable(url). As of April 2013, this is a list of 80 tables. The first 56 are for the 50 states and 6 territories. The remaining 24 are for the first letter of the last name of the representatives.

2. Use rbind to collapse these into 2 tables. The first has the district as a number without identifying the state (because that was with the names of the first 56 tables in House.gov). The second has the state names but with the district numbers in a form not easily parsed.

3. Obtain the state names from the second table to match the names of the representatives in the first.

4. Add a nonvoting column for those "States" in nonvoting.

5. Look for and fix surname and givenName with nonstandard characters using fixNonStandard.

See Also

getURL readHTMLTable readUSsenate UShouse.senate parseName readUSstateAbbreviations subNonStandardNames readCookPVI

Examples

Run this code
# NOT RUN {
if(!fda::CRAN()){
UShouse <- readUShouse()
}
# }

Run the code above in your browser using DataLab