Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

varUsed

Variables used in a random forest


Description

Find out which predictor variables are actually used in the random forest.

Usage

varUsed(x, by.tree=FALSE, count=TRUE)

Arguments

x

An object of class randomForest.

by.tree

Should the list of variables used be broken down by trees in the forest?

count

Should the frequencies that variables appear in trees be returned?

Value

If count=TRUE and by.tree=FALSE, a integer vector containing frequencies that variables are used in the forest. If by.tree=TRUE, a matrix is returned, breaking down the counts by tree (each column corresponding to one tree and each row to a variable).

If count=FALSE and by.tree=TRUE, a list of integer indices is returned giving the variables used in the trees, else if by.tree=FALSE, a vector of integer indices giving the variables used in the entire forest.

Author(s)

Andy Liaw

See Also

Examples

data(iris)
set.seed(17)
varUsed(randomForest(Species~., iris, ntree=100))

randomForest

Breiman and Cutler's Random Forests for Classification and Regression

v4.6-14
GPL (>= 2)
Authors
Fortran original by Leo Breiman and Adele Cutler, R port by Andy Liaw and Matthew Wiener.
Initial release
2018-03-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.