spot_funs_custom {funspotr} | R Documentation |
Spot Functions Custom
Description
Engine that runs spot_funs()
. spot_funs_custom()
has options for changing
returned output and for producing print statements and errors. It also
requires you to provide a character vector for pkgs
rather than identifying
these automatically via spot_pkgs()
.
Usage
spot_funs_custom(
pkgs,
file_path,
show_each_use = FALSE,
keep_search_list = FALSE,
copy_local = TRUE,
print_pkgs_load_status = FALSE,
error_if_missing_pkg = FALSE,
keep_in_multiple_pkgs = FALSE
)
Arguments
pkgs |
Character vector of packages that are added to search space via
|
file_path |
character vector of path to file. |
show_each_use |
Logical, default is |
keep_search_list |
Logical, default is |
copy_local |
Logical, if changed to |
print_pkgs_load_status |
Logical, default is |
error_if_missing_pkg |
Logical, default is |
keep_in_multiple_pkgs |
Logical, default is |
Details
spot_funs_custom()
is also what you should use in cases where you don't
trust spot_pkgs()
to properly identify package dependencies from within the
same file and instead want to pass in your own character vector of packages.
See README for a description of how the function works.
If a package is not included in pkgs
, any functions called that should come
from that package will be assigned a value of "(unknown)" in the pkgs
column of the returned output. You can also use the print_pkgs_load_status
and error_if_missing_pkg
arguments to alter how output works in cases when
not all packages are on the machine.
Explicit calls to unexported functions i.e. pkg:::fun()
will have pkgs = "(unknown)"
in the returned dataframe.
Value
Given default arguments and no missing packages, a dataframe with the following columns is returned:
funs
: specifying functions in file.
pkgs
: the package a function came from. If funs
is a custom function or
if it came from a package not installed on your machine, pkgs
will return
"(unknown)".
Note that any unused loaded packages / pkgs
are dropped from output.
Any functions without an available package are returned with the value
"(unknown)".
See README for further documentation.
See Also
Examples
library(funspotr)
file_lines <- "
library(dplyr)
require(tidyr)
library(madeUpPkg)
as_tibble(mpg) %>%
group_by(class) %>%
nest() %>%
mutate(stats = purrr::map(data,
~lm(cty ~ hwy, data = .x)))
made_up_fun()
"
file_output <- tempfile(fileext = ".R")
writeLines(file_lines, file_output)
pkgs <- spot_pkgs(file_output)
spot_funs_custom(pkgs, file_output)
# If you'd rather it error when a pkg doesn't exist e.g. for {madeUpPkg}
# set`error_if_missing_pkg = TRUE`