Learn R Programming

legislatoR (version 1.1.0)

get_portrait: Fetch 'Portrait' table

Description

Fetches portrait urls of legislators for the specified legislature. Requires a working Internet connection.

Usage

get_portrait(legislature)

Value

A data frame with columns as specified above.

Format

Data frame with columns (varies by legislature):

  • pageid: Wikipedia page ID identifying a legislator's Wikipedia biography (of class ‘integer’).

  • image_url: URL linking to a legislator's portrait on Wikimedia Commons (of class ‘character’).

Arguments

legislature

A character string specifying the three-letter country code of the legislature for which data shall be fetched. Currently one of ‘aut’, ‘can’, ‘cze’, ‘esp’, ‘fra’, ‘deu’, ‘irl’, ‘sco’, ‘gbr’, ‘usa_house’, or ‘usa_senate’.

Examples

Run this code
# Get entire 'Portraits' table for the United States Senate
usa_portraits <- get_portrait(legislature = "usa_senate")
tibble::glimpse(usa_portraits)

# Get 'Portraits' table for Democratic members of the United States Senate
usa_port_subset <- dplyr::semi_join(x = usa_portraits,
                                    y = dplyr::filter(get_political(legislature = "usa_senate"),
                                                                    party == "D"),
                                    by = "pageid")
tibble::glimpse(usa_port_subset)

Run the code above in your browser using DataLab