I'm writing some R code and I want to store a list of Function names and what they are for in a dataframe, and then query that dataframe to determine which function to call, but I can't figure out how to do this, or if it's even possible.
As a basic example, let's assume the function name is just stored as a string in a variable, how do I call the function based on the function name stored in that variable?
MyFunc <-function() {
# Do some stuff...
print("My Function has been called!!!")
return(object)
}
FuncName <- "MyFunc()"
Result <- FuncName
I need to make
Result <- FuncName
Work the same as
Result <- MyFunc()
Also, passing objects, or other variables, to the functions is not a concern for what I am doing here, so those () will always be empty. I realize passing variables like this might get even more complicated.
eval(parse(text = Result))what you want?