R/example.R

Defines functions readr_example

Documented in readr_example

#' Get path to readr example
#'
#' readr 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
#' @examples
#' readr_example()
#' readr_example("challenge.csv")
readr_example <- function(file = NULL) {
  if (is.null(file)) {
    dir(system.file("extdata", package = "readr"))
  } else {
    system.file("extdata", file, package = "readr", mustWork = TRUE)
  }
}
tidyverse/readr documentation built on Jan. 27, 2024, 11:59 p.m.