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.

find_functions(path, envir = .GlobalEnv, recursive = TRUE)

Arguments

path

Character, path to folder

envir

Environment to source loaded functions into

recursive

Logical, whether to search files recursively

Value

A tibble with character columns indicating path to source files and names of functions defined in them. Path elements are split into columns with `Level` prefix, name of source file is in `Source` column, name of function is in `Function` column.

Examples

# \donttest{ 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)
#> # A tibble: 3 x 10 #> Level1 Level2 Level3 Level4 Level5 Level6 Level7 Level8 Source Function #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 C: Users vc46qy AppData Local Temp RtmpU3~ find_funct~ code.R add #> 2 C: Users vc46qy AppData Local Temp RtmpU3~ find_funct~ code.R add_one #> 3 C: Users vc46qy AppData Local Temp RtmpU3~ find_funct~ code.R add_two
# }