Skip to contents

This function analyzes a given script to detect functions used in the `package::function` notation. It then generates `@importFrom` statements for each package detected, capturing the required dependencies for the script.

Usage

checkPkg_make_importFrom_fnctn_statments(script)

Arguments

script

A character string specifying the path to the R script file.

Value

This function generates and prints `@importFrom` statements for each package detected in the script.

Examples

ex_script <- "mtcars %>%
   dplyr::mutate(
     var_1 = DescTools::Quantile(disp, probs = .6),
     var_2 = str_glue('{disp} {hp}')
   ) %>%
   dplyr::arrange(disp)"
temp_script <- tempfile(fileext = ".R")
writeLines(ex_script, temp_script)
checkPkg_make_importFrom_fnctn_statments(temp_script)
#> Packages detected:
#> #' @importFrom DescTools Quantile
#> #' @importFrom dplyr arrange mutate
#> #' @importFrom magrittr %>%
#>                             DescTools                                 dplyr 
#>   "#' @importFrom DescTools Quantile" "#' @importFrom dplyr arrange mutate"