Reputation: 405
I want to know how to call a method of a R5 Class object by using a character variable of the name of the method. Say I have a R5 class object Object.R5 and it has a method called myMethod. The usual way we call the method is just typing:
Object.R5$myMethod()
However if I set a variable
method.name <- 'myMethod'
I'm wondering how can I call the method by using method.name? I tried:
do.call(paste("Object.R5$", method.name, "()", sep=""))
But this prompt an error message saying 'what' must be a character string or a function. I know the answer must be trivial but I'm new to R5 class so... anyone knows the answer please help.
Upvotes: 1
Views: 146