Description Usage Arguments Examples
View source: R/plot.DecisionTreeObject.R
plot a decision tree
1 2 3 | ## S3 method for class 'DecisionTreeObject'
plot(DecisionTreeObject, dict, green = 1,
left = 1)
|
DecisionTreeObject |
object of class DecisionTreeObject generated by function decisionTree |
dict |
a data.frame of optional names for nodes, colnames of data.frame are: vName and toPlot, remember about stringsAsFactors=F |
green |
which class should be coloured in green? 0 or 1? |
left |
which class should be mentioned on leaves |
1 2 3 4 5 6 7 8 9 10 11 | d <- iris[, c("Species", "Sepal.Length", "Sepal.Width")]
d$Species <- as.character(d$Species)
d$Species[d$Species != "setosa"] <- "non-setosa"
x <- d$Sepal.Length
x[d$Sepal.Length <= 5.2] <- "Very Short"
x[d$Sepal.Length > 5.2 & d$Sepal.Length <= 6.1] <- "Short"
x[d$Sepal.Length > 6.1 & d$Sepal.Length <= 7.0] <- "Long"
x[d$Sepal.Length > 7.0] <- "Very Long"
d$Sepal.Length <- x
decTree <- decisionTree(d, eta=5, purity=0.95, minsplit=0)
plot(decTree)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.