find_functions {functiondepends} | R Documentation |
Functions in path
Description
Parses files in given path. It searches for functions and loads them. Is safe for use with scripts as it doesn't source the whole file, just functions. There are no side-effects to sourcing .R files.
Usage
find_functions(
path,
envir = new.env(),
recursive = TRUE,
separate_path = FALSE
)
Arguments
path |
Character, path to folder |
envir |
Environment to source loaded functions into |
recursive |
Logical, whether to search files recursively |
separate_path |
Logical, whether to split path into hierarchy of directories. Produces multiple character columns with 'Level' prefix. |
Value
A tibble with character columns indicating path to source files and names of functions defined in them.
Examples
path <- file.path(tempdir(), "find_functions_example")
dir.create(path, showWarnings = FALSE)
code <- "
add <- function(x, y) {
x + y
}
add_one = function(x) {
add(x, 1)
}
assign('add_two', function(x) {
add(x, 2)
})
"
write(code, file.path(path, "code.R"))
find_functions(path)
[Package functiondepends version 0.2.3 Index]