1

I am following Titanic Tutorial on DataCamp. After built the decision tree, the plotting for the decision tree just doesn't work, showing an error that

there is no package called ‘rpart.plot’

Any idea how to fix this?

libraries

library(rattle)
library(rpart)
library(RColorBrewer)

decision tree

my_tree_two <- rpart(Survived ~ Pclass + Sex + Age + SibSp + Parch + Fare + Embarked, 
                     data = train, 
                     method = 'class')
fancyRpartPlot(my_tree_two)
Richard Telford
  • 9,558
  • 6
  • 38
  • 51
xmindata
  • 97
  • 1
  • 1
  • 10
  • 4
    Have you tried to manually `install.packages('rpart.plot')`? – loki Jan 08 '17 at 19:30
  • @loki He is using Datacamp's own interpreter, at times it is buggy and doesn't behaves as expected. If the package isn't available, I haven't been able to install on it so far. – Pj_ Jan 08 '17 at 19:40
  • @xmindata consider reporting it to Datacamp. These bugs should always be reported. – Pj_ Jan 08 '17 at 19:42
  • @loki yes I tried that, it's not working. – xmindata Jan 08 '17 at 21:01
  • Like @Pj_ said, there are several packages I cannot install. Thank you guys. – xmindata Jan 08 '17 at 21:01
  • @xmindata If the solution helped you, can you accept my answer so that it can help others too? :) – Pj_ Jan 08 '17 at 21:03

3 Answers3

4

Please try installing "rpart.plot":

library("rpart.plot")
Unheilig
  • 16,196
  • 193
  • 68
  • 98
3

The rpart.plot package should first be installed, then loaded in order to be used.

install.packages("rpart.plot")
library(rpart.plot)

The package does not install when you install rplot and must be installed with the above commands.

1

Datacamp's Interpreter at times it is buggy and doesn't behaves as expected. If the package isn't available, you won't be able to install it.

Consider reporting it to Datacamp

Pj_
  • 824
  • 6
  • 15