Skip to contents

Convenience wrapper around the rprojroot::is_r_package root criterion. Note that it will by default only return TRUE for the root of a package directory, not its subdirectories.

Usage

is_pkg_dir(path = ".", check_parent_dirs = FALSE)

Arguments

path

Path of the directory to check. A character scalar. Defaults to the current working directory.

check_parent_dirs

Whether or not to also check path's parent directories (up until the filesystem root) for an R package setup. Setting check_parent_dirs = TRUE guarantees that TRUE is returned for all subdirectories of an R package.

Value

TRUE if path is the root (if check_parent_dirs = FALSE) or a (sub)directory directory (if check_parent_dirs = TRUE) of an R package, FALSE otherwise.

See also

Other R package functions: assert_pkg(), is_pkg_cran(), is_pkg_installed(), is_pkgdown_dir(), ls_pkg(), use_pkg()

Examples

pal::is_pkg_dir()
#> [1] FALSE
pal::is_pkg_dir(fs::path_package("utils"))
#> [1] TRUE