pretty_namespace: Append namespace to functions in script

View source: R/pretty_namespace.R

pretty_namespaceR Documentation

Append namespace to functions in script

Description

Autoappend namespace to functions in script by searchpath order

Usage

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

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).

Value

character

Author(s)

Jonathan Sidi

See Also

findFn, help.search

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)


metrumresearchgroup/sinew documentation built on Feb. 28, 2024, 3:13 a.m.