Viewing the source code for a randomForest() function

r
random_forest

#1

Unlike other functions the source for randomForest() does’t come up when I write randomForest in R.
I’ve also tried some other commands like:

showMethods(“randomForest”)
Function “randomForest”:

getMethod(“randomForest”)
Error in getMethod(“randomForest”) :
no generic function found for ‘randomForest’

randomForest
function (x, …)
UseMethod(“randomForest”)
<environment: namespace:randomForest>

For other functions like classify_polarity() I could get the complete source code just by typing classify_polarity after importing the library (which is sentiment in this case).


#2

@crisis1.08

Hi there,

I would like you to follow the below steps in order to see the source code for the randomForest function.

 library(randomForest)
 randomForest

You will get an output something like below:

function (x, ...) 
UseMethod("randomForest")
<environment: namespace:randomForest>

Now since we were not able to see the source code at this instance. Let us see the other methods being employed by randomForest:

`methods(randomForest)`

You will get something like

[1] randomForest.default* randomForest.formula*

   Non-visible functions are asterisked

Now, We just need to look up the above two methods. Lets do it then.

  `getAnywhere(randomForest.default)`

Hope this helps.

Regards,
Neeraj