libr_used {nolock}R Documentation

'Get Packages Used in the Active Script'

Description

The 'libr_used()' retrieves a vector of package names actively utilized within an 'R' script; packages loaded using 'library()' but not actually used in the script will not be included.

Usage

libr_used(script = NULL)

Arguments

script

Character vector. 'R' script to be processed. If NULL, an active 'R' script is used.

Value

Returns the vector of all package names used in the active 'R' script, based on all the functions used in the script with fully loaded namespaces in the environment.

Examples

script_content <- 'library(rstudioapi)
ActiveDocument <- getActiveDocumentContext()$path
min_c <- min(c(1,2,3))
'

temp_script_path <- tempfile(fileext = ".R")
writeLines(script_content, con = temp_script_path)

libr_used(script = temp_script_path)

unlink(temp_script_path)

[Package nolock version 1.1.0 Index]