R cannot find a specific function in the package

I use the randomForest package (v 4.6-7) in R (v 2.15.3) and can easily use the randomForest function to create the model. However, when I try to predict on my test suite, the function pred.randomForest cannot be found. I also tried the plot with plot.randomForest just to get the same error, "could not find function".

I already tried to reinstall the package (maybe it is outdated) and made sure that the spelling is absolutely correct. I can’t understand what causes this error, any ideas?

+6
source share
1 answer

It seems that the functions of interest are not exported from the package.

If you use ls(package:randomForest) , you will get a list of exported functions.

If you want to see all the available functions, use: ls(getNamespace("randomForest"), all.names=TRUE) . Thanks @Joshua. You will see the features you want there.

To access one of them explicitly, use: randomForest:::predict.randomForest() or just create an object that inherits the class "randomForest" and calls predict() on it directly.

+7
source

Source: https://habr.com/ru/post/947796/


All Articles