R/wikkitidy-example.R

Defines functions wikkitidy_example

Documented in wikkitidy_example

#' Get path to wikkitidy example
#'
#' wikkitidy comes bundled with a number of sample files in its `inst/extdata`
#' directory. This function make them easy to access
#'
#' @param file Name of file. If `NULL`, the example files will be listed.
#' @export
#' @return A character vector, containing either the path of the chosen file, or
#'   the nicknames of all available example files.
#'
#' @keywords utility
#' @examples
#' wikkitidy_example()
#' wikkitidy_example("fatwiki_dump")
wikkitidy_example <- function(file = NULL) {
  if (is.null(file)) {
    names(.fn_map)
  } else {
    file <- rlang::arg_match(file, names(.fn_map))
    file <- .fn_map[[file]]
    system.file("extdata", file, package = "wikkitidy", mustWork = TRUE)
  }
}

.fn_map <- list(
  fatwiki_dump = "fatwiki-20240920-pages-articles-multistream.xml.bz2",
  fatwiki_index = "fatwiki-20240920-pages-articles-multistream-index.txt.bz2"
)

Try the wikkitidy package in your browser

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

wikkitidy documentation built on April 4, 2025, 12:41 a.m.