[R-pkg-devel] Dispatch for S3 and Ordinary Function with Same Name
Hi Dario, I would have suggested using randomForest::predict.randomForest but you cannot because it is not exported by randomForest :-( There is probably a better way but my workaround would be for you to define your own class to avoid the ambiguity in scope. Whenever you want to use the predict from randomForest rather than yours, I would just strip out your specific class name. Hopefully someone will advise something more elegant to force the scoping... ++ On Mon, 29 Aug 2022 at 17:00, Dario Strbenac <dstr7320 at uni.sydney.edu.au> wrote:
Good day,
If there is a function named predict in my package and another in another
package, such as randomForest, which is also called in a particular wrapper
function in my package, how may I ensure that the call to predict inside of
the wrapper function will call randomForest's prediction function and not
the predict function defined elsewhere in my package? To illustrate
randomForestPredictInterface <- function(forest, measurementsTest, ...)
{
predictions <- predict(forest, measurementsTest) # Currently, executes
predict defined in my package.
--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
______________________________________________ R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Alexandre Courtiol, www.datazoogang.de [[alternative HTML version deleted]]