Suppose I have a function with a name Fun1in which I use many different built-in R functions for different processes. Then, how can I get a list of built-in functions used inside this functionFun1
Fun1 <- function(x,y){
sum(x,y)
mean(x,y)
c(x,y)
print(x)
print(y)
}
So my output should be like a list of characters, i.e. sum, mean, c, print. Since these are built-in functions, I used an internal function Fun1.
I tried to use the function grep
grep("\\(",body(Fun1),value=TRUE)
# [1] "sum(x, y)" "mean(x, y)" "c(x, y)" "print(x)" "print(y)"
This looks fine, but the arguments should not come, i.e. xand y. Just a list of function names used inside the function body Fun1here.
So, my common goal is to print unique list of in-built functions or any create functions inside a particular function, here Fun1.
. .