3

When I typed the command for importance as below importance (model.rf) I get this error:

Error in UseMethod("importance") : no applicable method for 'importance' applied to an object of class "c('randomForest.formula', 'randomForest')"

How to solve this error?

FatihAkici
  • 4,679
  • 2
  • 31
  • 48
kruthika
  • 31
  • 1
  • 4
  • 3
    Did you try restarting your R session? It's possible you're masking the randomForest `importance()`. Try `randomForest::importance(model.rf)` – Megatron Sep 28 '16 at 13:15
  • You need to provide a minimal [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so we can see what you are really doing and what objects are involved. – MrFlick Sep 28 '16 at 14:34

1 Answers1

0
output.forest <- randomForest(nativeSpeaker ~ age + shoeSize + score,  data = 
readingSkills,importance=TRUE)
#You can use like this - Solution
out.importance <- round(importance(output.forest), 2)
print(out.importance )

first convert importance to variable and then print that out.