Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot a decision tree horizontally in R Markdown?

In R Markdown, I would like to plot a decision tree horizontally, so that it fits better the entire PDF page. This code plots it vertically:

```{r, message=FALSE, warning = FALSE, echo=FALSE, cache = FALSE}

rpart.lrn <- makeLearner("classif.rpart", predict.type = "prob", fix.factors.prediction = FALSE) 
model = train(rpart.lrn, task = classif.task, subset = train.set)
tree <- getLearnerModel(model)
rpart.plot(tree) # visualise the tree
```

How can I plot it horizontally instead?

like image 743
Javide Avatar asked Feb 03 '26 06:02

Javide


1 Answers

Have you tried so set fig.height and fig.width, for example {r ggpair, echo=FALSE, message = FALSE, warning = FALSE, fig.height = 12, fig.width = 12}

like image 170
PhilippPro Avatar answered Feb 05 '26 23:02

PhilippPro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!