get_package_names: Get used package names from R/qmd-files.

View source: R/get_package_names.R

get_package_namesR Documentation

Get used package names from R/qmd-files.

Description

E.g. for publication purposes it might be useful to quickly get all used package names out of a bunch of used scripts. This function takes the path to all the scripts and extracts the used package names if they are used in the manner "packagename::function()".

Usage

get_package_names(
  paths = c("."),
  file_endings = c("R", ".qmd"),
  pretty = TRUE,
  include_package_versions = TRUE
)

Arguments

paths

A character vactor with the paths to all files to be searched. Default: "." (so the current directory).

file_endings

A character vector containing the file types to search through. Default: "R" and "qmd". Case-sensitive!

pretty

Logical. If 'TRUE' (default), the result will be a single string containing all packages combined in one single string. If 'FALSE', the result will be a vector, containg all packages so one can apply the pretty formatting on his/her own.

include_package_versions

Logical. If 'TRUE' (default), the result will contain also the currently installed version of the package. If the package is not installed, the version will be needed to be fixed manually (output will be "tbd").

Value

A vector of all found package names.

Examples

## Not run: 
paths <- c("~", "/path/to/project/R")
get_package_names(
  paths = paths
)

## End(Not run)

DIZtools documentation built on Nov. 6, 2025, 1:10 a.m.