这里是一个 ha的解决办法。 它对从<条码>缔约方条码>一揽子计划中设定功能的原始源代码几乎没有改动。 通过阅读源代码,我注意到,如果结果是个因素,则有<条码>,即“终端_panel,即:<条码>_barplot<>。 (如果安装了源包,则每一条都在<代码>R/plot.R功能中。) 以后,我们可以修改,在缺货一览表中显示海关标签。
Just issue the following command at R prompt:
fixInNamespace("node_barplot", pos="package:party")
接着,开始增加我们想要的东西:
- Add
labels = NULL, gp = NULL
to the existing list of arguments for that function.
在“条码”之后,在<条码>网(gp = 准备(填充=“透明”)条码>之后,添加以下内容:
if (!is.null(labels)) {
labs <- as.character(labels[ctreeobj@where==node$nodeID])
len <- length(labs)
x <- unit(rep(0.5, len), "npc")
y <- unit(0.5:len/len, "npc")
for (i in 1:len)
grid.text(labs[i], x=x[i], y=y[i], just="center", gp=gp)
}
Here, the key idea is to select labels corresponding to the selected node (node$nodeID
), and we can grab this information from the slot where
of the ctree
object (this is a vector indicating in which node each case ended up). The if
test is just to ensure that we can use the function as originally written. The gp
argument can be used to change font size or color.
对这项职能的一项典型呼吁是:
plot(cfit, tp_pars=list(labels=dfrm$names))
<代码>dfrm$names为数据框架的标签一栏,名称为dfrm
。 下面是你数据的说明:
cfit <- ctree(young ~ age, data=a,
controls=ctree_control(minsplit=2, minbucket=2))
plot(cfit, tp_args=list(labels=a$names, gp=gpar(fontsize=8, col="darkgrey")))
。