R/06-browse.R

Defines functions view_url ons_browse_qmi ons_browse

Documented in ons_browse ons_browse_qmi

#' Quickly browse to ONS' developer webpage
#'
#' This function take you to the ONS' developer webpage.
#'
#' @export
#' @return An atomic character vector with the url of the webpage
#' @examples
#' \donttest{
#' ons_browse()
#' }
ons_browse <- function() {
  view_url("https://developer.ons.gov.uk/")
}

#' Quickly browse to dataset's Quality and Methodology Information (QMI)
#'
#' This function take you to the QMI.
#'
#' @inheritParams ons_get
#' @export
#' @return An atomic character vector url with of the webpage
#' @examples
#' \donttest{
#' ons_browse_qmi("cpih01")
#' }
ons_browse_qmi <- function(id = NULL) {
  ons_ds <- ons_datasets()
  ons_ds %||% return(invisible(NULL))
  assert_valid_id(id, ons_ds)
  id_num <- id_number(id, ons_ds)
  view_url(ons_ds$qmi$href[id_num])
}


view_url <- function(url, open = interactive()) {
  if (open) {
    utils::browseURL(url)
  }
  invisible(url)
}

Try the onsr package in your browser

Any scripts or data that you put into this service are public.

onsr documentation built on May 29, 2024, 2:50 a.m.