funInCode: Is a function used in some code?

View source: R/funInCode.R

funInCodeR Documentation

Is a function used in some code?

Description

Report whether a function name is used in some code. Only returns TRUE if it is followed by "(" or included as pack::fun

Usage

funInCode(funname, code)

Arguments

funname

Function name (character string)

code

Code (character string)

Author(s)

Berry Boessenkool, berry-b@gmx.de, Aug 2017

See Also

https://stackoverflow.com/questions/45691254

Examples

if(FALSE){ # not run, since funInCode is no longer exported
code <- "mean(pi); head(data.frame(A=1:5)); data_frame(7:9); do.call(base::print, list(pi))"
funs <- c("mean", "head", "head.data.frame",  "data.frame", "frame", "data_frame", "base::print")
data.frame(isfound=sapply(funs, funInCode, code=code), 
           shouldbefound=c(TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE))
           
funInCode("ABC::pack.dep", "ABC::pack_dep(A)")
}


brry/installB documentation built on Jan. 3, 2024, 6:49 p.m.