In this vignette we use twfy to take a look at the MP for Keighley, West Yorkshire.


We can get its detailed by name or by any postcode

keighley <- getConstituency("Keighley")

Who is the current MP? This time we’ll use the postcode lookup

mp <- getMP(postcode="BD21 2DH")

Keighley’s MP is

## [1] "John Grogan"

He’s a member of the Labour Party

## [1] "Labour"

and since we’re in England he’s in the House of Commons, represented as 1.

## [1] "1"

We can find him with two identifiers, the identifier for his current term in office

## [1] "41872"

but more lastingly by his person id

## [1] "10248"

With person_id we can get the details of all of his spells in the House of Commons like this

mp_per <- getPerson(mp$person_id)

Now, what’s he been talking about in Parliamentary debates?

mp_talk <- getDebates(person=mp$person_id)

Debate results are fairly structured objects

## [1] "info"              "searchdescription" "rows"
names(mp_talk$info) # what we've got to work with
## [1] "s"                   "results_per_page"    "page"               
## [4] "first_result"        "total_results"       "spelling_correction"

the output is paged, so there are

## [1] 519

entries, of which we are seeing from

## [1] 20

counting from

## [1] 1

to get the second page, we’d call getDebates again specifying page=2.

Let’s take a look at the first recorded entry

first_entry <- mp_talk$rows[1,]
## [1] "2010-04-08"

clarifying an important issue

## [1] "<p pid=\"b.1177.6/1\">Will the Secretary of State say a few words about the impact of the proposed level of feed-in tariffs on the development of anaerobic digestion plants such as the proposed Selby renewable energy plant, which is set to power 10,000 homes in the town?</p>"

The speaker field embeds a data.frame with the speaker’s details, from which we note that he was not representing Keighley at that time but rather

## [1] "Selby"