# real API access requires a key so these are prefetched # results from June 23, 2017 load('prefetched.rda')
In this vignette we use twfy
to take a look at the MP for Keighley, West Yorkshire.
library(twfy)
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
mp$full_name
He's a member of the Labour Party
mp$party
and since we're in England he's in the House of Commons, represented as 1.
mp$house
We can find him with two identifiers, the identifier for his current term in office
mp$member_id
but more lastingly by his person id
mp$person_id
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
names(mp_talk) names(mp_talk$info) # what we've got to work with
the output is paged, so there are
mp_talk$info$total_results
entries, of which we are seeing from
mp_talk$info$results_per_page
counting from
mp_talk$info$first_result
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,] first_entry$hdate
clarifying an important issue
first_entry$body
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
first_entry$speaker$constituency
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.