-1

Please help me I am not able plot using fancyRpart command though I have installed rattle and other dependency like RGtk2,rpart.plot& rpart.

I am using R version 3.4.2 (2017-09-28) on windows 10 getting following error set.seed(123456)

modelFit<-train(classe ~.,method="rpart", data=TrainSet)

fancyrpartPlot(modelFit)

Error: the object passed to prp is not an rpart object In addition: Warning message: In max(model$frame$yval) : no non-missing arguments to max; returning -Inf

Community
  • 1
  • 1
  • 1
    Please add some example data and code. It might be useful to read [this guide](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on how to make a reproducible example – alan ocallaghan Jan 14 '18 at 20:28

1 Answers1

0

Please do provide complete reproducible exapmles otherwise we have to guess.

I think you are using caret::train(). This returns an object of class "train", not the actual final model but it does encapsulate the model and much more meta data: see ?caret::train.

Try:

fancyRpartPlot(modelFit$finalModel)

A reproducible example:

library(caret)
library(rattle)

modelFit<-train(Species ~., method="rpart", data=iris)
fancyRpartPlot(modelFit$finalModel)
Graham Williams
  • 556
  • 2
  • 10