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
##  "John Grogan"
He’s a member of the Labour Party
##  "Labour"
and since we’re in England he’s in the House of Commons, represented as 1.
##  "1"
We can find him with two identifiers, the identifier for his current term in office
##  "41872"
but more lastingly by his person id
##  "10248"
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
##  "info" "searchdescription" "rows"
names(mp_talk$info) # what we've got to work with
##  "s" "results_per_page" "page" ##  "first_result" "total_results" "spelling_correction"
the output is paged, so there are
##  519
entries, of which we are seeing from
##  20
##  1
to get the second page, we’d call
getDebates again specifying
Let’s take a look at the first recorded entry
first_entry <- mp_talk$rows[1,] first_entry$hdate
##  "2010-04-08"
clarifying an important issue
##  "<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>"
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
##  "Selby"