R/bfs_get_catalog.R

Defines functions bfs_get_catalog

Documented in bfs_get_catalog

#' Get the BFS data or table catalog
#'
#' This function scraps a given RSS Feed of the Swiss Federal Statistical Office.
#'
#' @param language character The language of a BFS catalog.
#' @param type character A BFS catalog
#'
#' @return A data frame
#'
#' @importFrom tidyRSS tidyfeed
#' @importFrom janitor clean_names
#'
#' @seealso \code{\link{bfs_get_data}}
#'
#' @export
bfs_get_catalog <- function(language = "de", type = "data") {
  if (missing(language)) stop("must choose a language, either 'de', 'fr', 'it' or 'en'", call. = FALSE)
  language <- match.arg(arg = language, choices = c("de", "fr", "it", "en"))
  if (missing(type)) stop("must choose a type, either 'data' or 'tables'", call. = FALSE)
  type <- match.arg(arg = type, choices = c("data", "tables"))
  if (type == "data") {
    BFS::bfs_get_catalog_data(language = language)
  }
  if (type == "tables") {
    BFS::bfs_get_catalog_tables(language = language)
  }
}

Try the BFS package in your browser

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

BFS documentation built on Sept. 20, 2023, 5:07 p.m.