Autoappend namespace to functions in script by searchpath order

pretty_namespace(
  con = NULL,
  text = NULL,
  ask = TRUE,
  askenv = new.env(),
  force = NULL,
  ignore = NULL,
  overwrite = FALSE,
  sos = FALSE
)

Arguments

con

character, path to file or directory that contains script, Default: NULL

text

character, vector that contains script, Default: NULL

ask

boolean, If TRUE then a menu will be created for the use to choose between competing namespaces for a function, Default: TRUE

askenv

environment, environment that stores names of functions to force in ask, Default: new.env()

force

list, named list of functions to force over the internal search (seee details), Default: NULL

ignore

list, named list of functions to ignore (seee details), Default: NULL

overwrite

boolean, overwrite original file, Default: FALSE

sos

boolean, apply sos search for uninstalled libraries, Default: FALSE

Value

character

Details

Searches for functions in the loadedNamespace, help.search and then findFn. If force is not NULL but a named list eg list(stats=c('rnorm','runif'),utils = 'head'), then the value pairs will be used in place of what was found using the search path. If ignore is not NULL but a named list eg list(stats=c('rnorm','runif'),utils = 'head'), then if the functions are found they will not have a namespace attached to them.

If you want to toggle off the summary console printing you can set it globally via sinew_opts$set(pretty_print=FALSE).

See also

Author

Jonathan Sidi

Examples

txt <- '#some comment
yy <- function(a=4){
  head(runif(10),a)
  # a comment
}

zz <- function(v=10,a=8){
  head(runif(v),a)
}'

pretty_namespace(text=txt)
#> 
#> functions changed in 'text object':
#> 
#> ✔: found, : not found, (): instances, ☒: user intervention
#> 
#>  ✔ utils::head  (2) 
#>  ✔ stats::runif (2) 
#> 
#> #some comment
#> yy <- function(a=4){
#>   utils::head(stats::runif(10),a)
#>   # a comment
#> }
#> 
#> zz <- function(v=10,a=8){
#>   utils::head(stats::runif(v),a)
#> }