Title: | Alternative Tree Representation |
Date: | 2020-01-08 |
Version: | 0.1-1 |
Description: | Plot party trees in left-right orientation instead of the classical top-down layout. |
Depends: | grid, partykit |
Suggests: | trtf, mlbench |
Imports: | stats |
License: | GPL-2 |
NeedsCompilation: | no |
Packaged: | 2020-01-09 14:26:29 UTC; hothorn |
Author: | Jon Eugster [ctr],
Andrea Farnham [ctr],
Raphael Hartmann [ctr],
Tea Isler [ctr],
Gilles Kratzer [ctr],
Ke Li [ctr],
Silvia Panunzi [ctr],
Sophie Schneider [ctr],
Craig Wang [ctr],
Torsten Hothorn |
Maintainer: | Torsten Hothorn <Torsten.Hothorn@R-project.org> |
Repository: | CRAN |
Date/Publication: | 2020-01-09 19:40:05 UTC |
Change the class of a party
object.
Description
Adds a new class to party objects allowing rotated tree visualisations.
Usage
rotate(m, to = "left", ...)
Arguments
m |
an object of class |
to |
a character, only |
... |
additional arguments, currently ignored. |
Details
Adds a new class allowing for improved tree printing.
Note
This package was written by the students participating in the Advanced R Programming course taught in spring semester 2017 at University of Zurich.
Examples
data("airquality", package = "datasets")
m <- ctree(Wind ~ . , data = airquality)
plot(rotate(m), main = "TREE", tnex = 1.5)
if (require("trtf")) {
data("Ozone", package = "mlbench")
Ozone <- subset(Ozone, complete.cases(Ozone))
Ozone <- as.data.frame(lapply(Ozone, function(x) {
x <- x[, drop = TRUE]
if (is.factor(x)) return(as.ordered(x))
x
}))
response <- "V4"
Ozone[[response]] <- as.numeric(Ozone[[response]])
ns <- 20
fm <- V4 ~ V1 + V2 + V3 + V5 + V6 + V7 + V8 + V9 + V10 + V11 + V12 + V13
mtry <- ceiling(length(all.vars(fm[[3]])) / 3)
var_m <- numeric_var("V4", support = quantile(Ozone[[response]], prob = c(.1, .9)),
add = range(Ozone[[response]]) -
quantile(Ozone[[response]], prob = c(.1, .9)),
bounds = c(0, Inf))
B_m <- Bernstein_basis(var_m, order = 4, ui = "increasing")
uc_ctm_Ozone <- ctm(B_m, data = Ozone, todistr = "Normal")
tt_Ozone <- trafotree(uc_ctm_Ozone, formula = fm, data = Ozone,
control = ctree_control(mincriterion = .95, minsplit = 2*ns,
minbucket = ns))
plot(rotate(tt_Ozone), tp_args = list(type = "density", id = FALSE,
ylines = 0, K = 100, fill = "lightgrey"),
terminal_panel = trtf:::node_mlt)
}