Nothing
#' House of Commons constituencies
#'
#' Imports data on House of Commons constituencies, returning a tibble of all
#' current and/or former Westminster constituencies, subject to parameters.
#'
#' @param current If `TRUE`, returns only current constituencies. If
#' `FALSE`, returns only former constituencies. If `NULL`, returns
#' all current and former constituencies. Defaults to `NULL`.
#' @inheritParams all_answered_questions
#' @return A tibble with details of Westminster constituencies.
#' @export
#' @examples
#' \dontrun{
#' x <- constituencies()
#'
#' y <- constituencies(current = FALSE)
#' }
#'
constituencies <- function(current = NULL, extra_args = NULL, tidy = TRUE,
tidy_style = "snake", verbose = TRUE) {
baseurl <- paste0(url_util, "constituencies.json?")
if (verbose == TRUE) {
message("Connecting to API")
}
conts <- jsonlite::fromJSON(paste0(baseurl, extra_args), flatten = TRUE)
jpage <- floor(conts$result$totalResults / 100)
if (is.null(current)) {
current_query <- ""
} else if (current == TRUE) {
current_query <- "&exists-endedDate=false"
} else if (current == FALSE) {
current_query <- "&exists-endedDate=true"
} else {
current_query <- ""
}
query <- paste0(baseurl, extra_args, current_query)
df <- loop_query(query, jpage, verbose) # in utils-loop.R
if (nrow(df) == 0) {
message("The request did not return any data.
Please check your parameters.")
} else {
if (tidy == TRUE) {
df <- cons_tidy(df, current, tidy_style)
}
df
}
}
#' @rdname constituencies
#' @export
hansard_constituencies <- constituencies
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.