if(Date=NULL)
Date <- Sys.Date()
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$Honours)
}
Date <- Sys.Date()
House = "Commons"
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
x
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(Date=NULL)
Date <- Sys.Date()
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(Date=NULL)
Date <- Sys.Date()
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
rm(list=ls())
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(Date=NULL)
Date <- Sys.Date()
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
if(Date=NULL)
Date <- Sys.Date()
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
library(mnis)
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(Date==NULL)
Date <- Sys.Date()
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_PartyState()
x <- mnis_PartyState(House = "Commons")
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(is.null(Date)==TRUE) {
Date <- Sys.Date()}
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_PartyState(House = "Commons")
x <- mnis_PartyState()
rm(list=ls())
mnis_LordsType <- function(Date = NULL) {
if(is.null(Date)==TRUE) {
Date <- Sys.Date()}
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/LordsByType/"
query <- paste0(baseurl, Date, "/")
got <- httr::GET(query, httr::accept_json())
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$LordsByType)
}
x <- mnis_LordsType()
View(x)
roxygen2::roxygenise()
library(mnis)
x <- mnis_MemberDate()
mnis_MemberDate <- function(ID = NULL, Date = NULL) {
if(is.null(ID)==TRUE) {
stop()
}
if(is.null(Date)==TRUE) {
Date <- Sys.Date()
}
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/member/historical/"
query <- paste0(baseurl, ID, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_MemberDate()
mnis_MemberDate <- function(ID = NULL, Date = NULL) {
if(is.null(ID)==TRUE) {
stop(call. = FALSE)
}
if(is.null(Date)==TRUE) {
Date <- Sys.Date()
}
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/member/historical/"
query <- paste0(baseurl, ID, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_MemberDate()
mnis_MemberDate <- function(ID = NULL, Date = NULL) {
if(is.null(ID)==TRUE) {
stop("ID cannot be empty", call. = FALSE)
}
if(is.null(Date)==TRUE) {
Date <- Sys.Date()
}
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/member/historical/"
query <- paste0(baseurl, ID, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_MemberDate()
x <- mnis_MemberDate(172)
x <- mnis_MemberDate(172, 2009-10-11)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/member/historical/"
query <- paste0(baseurl, ID, "/", Date, "/")
ID=172
date="2009-10-11"
query <- paste0(baseurl, ID, "/", Date, "/")
Date="2009-10-11"
query <- paste0(baseurl, ID, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
got$Member
rm(list=ls())
library(mnis)
roxygen2::roxygenise()
library(mnis)
x <- mnis_MemberDate(172)
mnis_MemberDate <- function(ID = NULL, Date = NULL) {
if(is.null(ID)==TRUE) {
stop("ID cannot be empty", call. = FALSE)
}
if(is.null(Date)==TRUE) {
Date <- Sys.Date()
}
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/member/historical/"
query <- paste0(baseurl, ID, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$Member)
}
x <- mnis_MemberDate(172)
x <- mnis_MemberDate(172, "2009-08-11")
x <- mnis_PartyState(Date = 2010-12-01)
library(mnis)
x <- mnis_PartyState(Date = 2010-12-01)
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(is.null(Date)==TRUE) {
Date <- Sys.Date()
}
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_PartyState(Date = 2010-12-01)
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(is.null(Date)==TRUE) {
Date <- Sys.Date()
}
Date <- as.character(Date)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_PartyState(Date = 2010-12-01)
x <- mnis_PartyState(Date = "2010-12-01")
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(is.null(Date)==TRUE) {
Date <- Sys.Date()
}
Date <- URLencode(Date)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_PartyState(Date = 2010-12-01)
mnis_PartyState <- function(House = "Commons", Date = NULL) {
if(is.null(Date)==TRUE) {
Date <- Sys.Date()
}
Date <- as.character(Date)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/HouseOverview/"
query <- paste0(baseurl, House, "/", Date, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$HouseOverview)
}
x <- mnis_PartyState()
rm(list=ls)
rm(list=ls())
roxygen2::roxygenise()
library(mnis)
library(mnis)
roxygen2::roxygenise()
library(mnis)
library(mnis)
roxygen2::roxygenise()
mnis_ConstituencyResults <- function(constituencyId = NULL, electionId = NULL) {
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/ConstituencyResults/"
query <- paste0(baseurl, constituencyId, "/", electionId, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- as.data.frame(got$ConstituencyResults)
}
x <- mnis_ConstituencyResults(3701, 0)
x
x <- mnis_ConstituencyResults(3701, 19)
x
constituencyId=3701
electionId=19
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/ConstituencyResults/"
query <- paste0(baseurl, constituencyId, "/", electionId, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
got$Constituency
got$Constituency$Details
x <- as.data.frame(got$Constituency$Details)
x <- as.data.frame(got$Constituency$Details[[1]])
x
class(got$Constituency$Details)
got$Constituency$Details
data.table::rbindlist(got$Constituency$Details
)
x <- (got$Constituency$Details)
data.table::rbindlist(x)
class(got$Constituency$Details$Name)
class(got$Constituency$Details)
x <- got$Constituency$Details
x <- as.data.frame(x)
got$Constituency$Results
class(got)
x <- as.matrix(x)
x <- got
x <- as.matrix(x)
x
class(x)
x[,1]
class(x[,1])
locationType = "England"
locationName = "England"
locationType = "Country"
startDate = "2010-01-01"
endDate = Sys.Date()
query <- paste0(baseurl, locationType, "/", locationName, "/", startDate, "/", endDate, "/")
query
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/GeneralElectionResults/"
query <- paste0(baseurl, locationType, "/", locationName, "/", startDate, "/", endDate, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
x <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
got$ElectionResults
got$ElectionResults$LocationInfo
got$ElectionResults$ElectionResult
roxygen2::roxygenise()
library(mnis)
former <- "current"
departmentId = 0
bench = "Government"
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/Department/"
query <- paste0(baseurl, departmentId, "/", bench, "/", former, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
got$Department
got$Department$Details
got$Department$Details[1]
got$Department$Details[[1]]
got$Department$Posts
head(got$Department$Posts)
x <- got$Department$Posts
x <- as.data.frame(x)
head(x)
names(x)
mnis_Department <- function(departmentId = 0, bench = "Government", former=TRUE) {
if(former==TRUE) {
former <- "former"
} else {
former <- "current"
}
bench <- URLencode(bench)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/Department/"
query <- paste0(baseurl, departmentId, "/", bench, "/", former, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- got$Department$Posts
x <- as.data.frame(x)
names(x) <- gsub("Post.PostHolders.", "", names(x))
names(x) <- gsub("..", ".", names(x))
names(x) <- gsub(".", "_", names(x))
x
}
x <- mnis_Department(former=FALSE)
x
head(x)
names(x)
mnis_Department <- function(departmentId = 0, bench = "Government", former=TRUE) {
if(former==TRUE) {
former <- "former"
} else {
former <- "current"
}
bench <- URLencode(bench)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/Department/"
query <- paste0(baseurl, departmentId, "/", bench, "/", former, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- got$Department$Posts
x <- as.data.frame(x)
names(x) <- gsub("Post.PostHolders.", "", names(x))
x
}
x <- mnis_Department(former=FALSE)
x
head(x)
mnis_Department <- function(departmentId = 0, bench = "Government", former=TRUE) {
if(former==TRUE) {
former <- "former"
} else {
former <- "current"
}
bench <- URLencode(bench)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/Department/"
query <- paste0(baseurl, departmentId, "/", bench, "/", former, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- got$Department$Posts
x <- as.data.frame(x)
names(x) <- gsub("Post.PostHolders.", "", names(x))
names(x) <- gsub("..", ".", names(x))
#names(x) <- gsub(".", "_", names(x))
x
}
x <- mnis_Department(former=FALSE)
x
head(x)
mnis_Department <- function(departmentId = 0, bench = "Government", former=TRUE) {
if(former==TRUE) {
former <- "former"
} else {
former <- "current"
}
bench <- URLencode(bench)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/Department/"
query <- paste0(baseurl, departmentId, "/", bench, "/", former, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- got$Department$Posts
x <- as.data.frame(x)
names(x) <- gsub("Post.PostHolders.", "", names(x))
names(x) <- sub("..", ".", names(x))
#names(x) <- gsub(".", "_", names(x))
x
}
x <- mnis_Department(former=FALSE)
x
head(x)
mnis_Department <- function(departmentId = 0, bench = "Government", former=TRUE) {
if(former==TRUE) {
former <- "former"
} else {
former <- "current"
}
bench <- URLencode(bench)
baseurl <- "http://data.parliament.uk/membersdataplatform/services/mnis/Department/"
query <- paste0(baseurl, departmentId, "/", bench, "/", former, "/")
got <- httr::GET(query, httr::accept_json())
if (httr::http_type(got) != "application/json") {
stop("API did not return json", call. = FALSE)
}
got <- jsonlite::fromJSON(httr::content(got, "text"), flatten = TRUE)
x <- got$Department$Posts
x <- as.data.frame(x)
names(x) <- gsub("Post.PostHolders.", "", names(x))
x
}
rm(list=ls())
library(mnis)
library(mnis)
library(mnis)
??URLencode
library(mnis)
library(mnis)
library(mnis)
roxygen2::roxygenise()
library(mnis)
library(mnis)
roxygen2::roxygenise()
library(mnis)
library(mnis)
library(mnis)
roxygen2::roxygenise()
library(mnis)
library(mnis)
formatR::tidy_dir("R")
roxygen2::roxygenise()
library(mnis)
hansard::members_search("turton")
x<-hansard::members_search("turton")
x
x<-hansard::members_search("touche")
x<-hansard::members_search("tomne")
x
x<-hansard::members_search("tinn")
x
x<-hansard::members_search("tink")
x<-hansard::members_search("tiln")
x<-hansard::members_search("thur")
x
x<-hansard::members_search("thurt")
x<-hansard::members_search("thorton")
hansard::members_search("fletcher")
x<-hansard::members_search("fletcher")
x
x<-hansard::members_search("hylton")
x
x<-hansard::members_search("hurd")
x
x<-hansard::members_search("holman")
x<-hansard::members_search("dingle")
x
x<-hansard::members_search("foot")
x
x<-hansard::members_search("boyle")
x
x<-hansard::members_search("atlee")
x<-hansard::members_search("attlee")
x
x<-hansard::members_search("kinnock")
x
