Lets say I have a function named Fun1
within which I am using many different in-built functions of R for different different processes. Then how can I get a list of in-built functions used inside this function Fun1
Fun1 <- function(x,y){
sum(x,y)
mean(x,y)
c(x,y)
print(x)
print(y)
}
So My output should be like list of characters i.e. sum
, mean
, c
, print
. Because these are the in-built functions I have used inside function Fun1
.
I have tried using grep
function
grep("\\(",body(Fun1),value=TRUE)
# [1] "sum(x, y)" "mean(x, y)" "c(x, y)" "print(x)" "print(y)"
It looks ok, but arguments should not come i.e. x
and y
. Just the list of function names used inside body of function Fun1
here.
So my overall goal is to print the unique list of in-built functions or any create functions inside a particular function
, here Fun1
.
Any help on this is highly appreciated. Thanks.