
The idea is to specify a panel functions for plotting inner nodes.
I generate some data, and the tree
lls <- data.frame(N = gl(3, 50, labels = c("A", "B", "C")),
a = rnorm(150) + rep(c(1, 0,150)),
b = runif(150))
pond= sample(1:5,150,replace=TRUE)
tt <- ctree(formula=N~a+b, data=lls,weights = pond)
The custom inner plot function. I draw a circle where i write the some of weights.
innerWeights <- function(node){
grid.circle(gp = gpar(fill = "White", col = 1))
mainlab <- paste( node$psplit$variableName, "\n(n = ")
mainlab <- paste(mainlab, sum(node$weights),")" , sep = "")
grid.text(mainlab,gp = gpar(col='red'))
}
I plot the tree
plot(tt, type='simple', inner_panel = innerWeights)
PS: the results depends on a random generated data, so you will not probably get the same plot.