The partykit
package give a nice representation of decision trees. The only problem I have with it is when labels are long and then they are overlapping. Is it possible to move those labels to prevent it (see the blue arrows on the picture below)?
library("rpart")
library("partykit")
rp <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis)
party_rp <- as.party(rp)
plot(party_rp)
The default panel function for drawing the edge labels edge_simple
implements a few justification strategies: Labels can either "alternate"
across the edges, be "decreasing"
, "increasing"
, or "equal"
. However, these justification strategies are just employed starting from a minimum label length of justmin
which defaults to Inf
(i.e., no justification). See ?edge_simple
for more details.
You wanted to see an example where justification is "increasing"
and always applied (i.e., justmin = 1
):
plot(party_rp,
ep_args = list(justmin = 1, just = "increasing"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With