example_files {basepenguins} | R Documentation |
List or find example files from basepenguins package
Description
These functions provides access to example files included with the basepenguins package.
When example_files()
is called with path = NULL
, it lists available example files.
When called with a specific path, it returns the full path to that file.
example_dir()
provides the path to the directory containing the examples,
and also takes a copy.dir
argument which, if specified, will copy all the
example files to a new directory. This is useful for testing the convert_dir_inplace()
and convert_files_inplace()
functions without overwriting package files.
Usage
example_files(path = NULL, full.names = FALSE, recursive = TRUE)
example_dir(copy.dir = NULL)
Arguments
path |
Character string. If |
full.names |
Logical. If |
recursive |
Logical. If |
copy.dir |
Character string. A directory name or path to a directory
into which the files in the example directory will be copied.
If |
Details
There are four example files in the example directory:
penguins.R - an R script using the palmerpenguins package
no_penguins.Rmd - an Rmarkdown file with
ends_with("_mm")
, but not in the context of the palmerpenguins packagenested/penguins.qmd - a Quarto document that uses the palmerpenguins package
nested/not_a_script.md - contains
library(palmerpenguins)
, but is not a script, i.e. not one of the default extensions for the convert functions.
Value
example_files
:
If
path = NULL
, a character vector of available file/directory names.If
path
is specified, the absolute path to the requested file.
example_dir
:
If
copy.dir = NULL
, the absolute path to the directory containing all examples.If
copy.dir
is specified, the specified directory is created if it doesn't already exist, and all example files are copied into it, preserving nesting structure. The absolute path to the directory is returned invisibly.
Examples
# List all files in the example directory provided by the package
example_files()
# Get the full path to a specific example files
example_files("penguins.R") # path/to/basepenguins/extdata/penguins.R
example_files("nested/penguins.qmd")
# Get the path to the directory containing the example files
example_dir() # path/to/basepenguins/extdata/
# Copy all files in the example directory
example_dir(".") # copy example files into working directory
example_dir("examples") # create subdirectory