#' Paths to example data installed in any package at `.libPaths()`
#'
#' @param path Name of file.
#' @param package Character string giving the name of a single package. `NULL`
#' defaults to the current
#'
#' @family miscellaneous utility functions
#'
#' @return
#' * `path_example()`: A path to a single example.
#' * `path_examples()`: A character vector of all built-in examples.
#'
#' @export
#'
#' @examples
#' path_examples("readr")
#' path_example("mtcars.csv", package = "readr")
path_examples <- function(package) {
dir(system.file("extdata", package = package, lib.loc = .libPaths()))
}
#' @rdname path_examples
#' @export
path_example <- function(path, package) {
system.file(
"extdata", path,
package = package, mustWork = TRUE, lib.loc = .libPaths()
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.