I have hit a problem in R trying to call a function when the function name is stored in a variable. From the forum I can see that get(funcName) would work but what if the function is in a reference class?
Example below:
TestClass <- setRefClass("TestClass",
fields = c("x", "y"),
methods = list(
say_hello = function() message("Hi")
)
)
myTest <- TestClass(x=2, y=3)
myTest$say_hello() # works ok
# Now i'd like to use the call by using the name of the function in a variable
funcName <- "say_hello"
get(funcName) # this would work if not a class
get(funcName,myTest) #this gives me the function definition and does not run the function
Any pointers would be great!