Learn R Programming

Ecfun (version 0.1-4)

readUSsenate: Read the list of elected officials in the United States Senate

Description

Read the list of elected officias in the United States Senate.

Usage

readUSsenate(url.=
"http://en.wikipedia.org/wiki/List_of_current_United_States_Senators",
    stateAbbreviations=Ecdat::USstateAbbreviations,
   fixNonStandard=subNonStandardNames, ...)

Arguments

url.
Universal resource locator to be read and processed to obtain the desired list NOTE: On April 26, 2013 the obvious naive use of readHTMLTable worked with the Wikipedia article
stateAbbreviations
a data.frame giving names and alternative codes for US states and territories. This must have a column named "Name" giving the names of all 50 states as they appear on the url and
fixNonStandard
function to look for and repair nonstandard names such as names containing characters with accent marks that are sometimes mangled by different software.
...
optional arguments passed to fixNonStandard

Value

  • readUSsenate returns a data.frame with the following columns:
  • StateA factor identifying the state the person represents
  • stateA factor giving the 2-letter USPS code for the state represented
  • Class"1", "2", or "3" for election in the 6-year cycle including 2008, 2010, or 2012, respectively.
  • NameA character vector giving the name of each representative (in surname, given name format)
  • Partya factor identifying the party affiliation of each representative ("Democrat", "Republican", or "Independent").
  • Experiencecharacter vector highlighting prior experience.
  • assumedOfficecharacter vector giving the date assumed office
  • Borna character vector giving the year of birth
  • endOfficea character vector giving the last day in the present term.
  • surnamecharacter vector giving the surname of each representative
  • givenNamegiven name of each representative (possibly with middle name or initial, a nickname, and a suffix like "Jr.")

Details

1. Senate <- readHTMLTable(url) 2. Use camelParse to remove duplication in Name. 3. Look for and fix surname and givenName with nonstandard characters using fixNonStandard.

See Also

getURL readHTMLTable camelParse to remove duplication in Name readUShouse UShouse.senate parseName subNonStandardNames

Examples

Run this code
if(!fda::CRAN()){
USsenate <- readUSsenate()
}

Run the code above in your browser using DataLab