从派对包中打印一棵大树

时间:2014-05-26 18:24:51

标签: r tree party

我使用party中的R包创建了一个树。树很好,但它非常大(27个终端节点)。尝试打印它会导致文件不可读,椭圆形相互重叠。

如何创建可读的内容?

我可以打印树的子部分吗?例如。第一页包含前几个节点,然后是后面的页面从孙女节点开始?

有关可视化此类树的任何其他建议吗?

EDIT 斯蒂芬要求一个可重复的例子;这很合理但很难;变量的相互关系是存在树的关键,而那些很难(至少对我来说!)来模拟。此外,一些变量是分类的,一些是连续的。但是这里是在R中打印树结构的输出版本。(我用V1代替变量名)

1) v1 == {AS, IT, LS, NS}; criterion = 1, statistic = 106.413
  2) v2 <= 0; criterion = 1, statistic = 37.039
    3) v1 == {NS}; criterion = 1, statistic = 34.458
      4)*  weights = 316 
    3) v1 == {AS, IT, LS}
      5) V3 <= 2; criterion = 1, statistic = 28.409
        6) V4 <= 0; criterion = 0.997, statistic = 15.053
          7) v5 == {A: Maste, B: Bache, C: Assoc}; criterion = 0.964, statistic = 15.43
            8) V6 <= 24.1068; criterion = 0.98, statistic = 11.242
              9)*  weights = 259 
            8) V6 > 24.1068
              10)*  weights = 886 
          7) v5 == {D: Plus2}
            11)*  weights = 38 
        6) V4 > 0
          12) V7 <= 0; criterion = 1, statistic = 22.142
            13)*  weights = 440 
          12) V7 > 0
            14) V8 <= 1; criterion = 0.999, statistic = 17.06
              15)*  weights = 88 
            14) V8 > 1
              16)*  weights = 59 
      5) V3 > 2
        17)*  weights = 100 
  2) v2 > 0
    18)*  weights = 41 
1) v1 == {, BM, CJ, HS}
  19) V4 <= 0; criterion = 1, statistic = 60.5
    20) V7 <= 0; criterion = 1, statistic = 41.949
      21) V9 <= 0; criterion = 0.985, statistic = 15.936
        22)*  weights = 376 
      21) V9 > 0
        23) V8 <= 1; criterion = 1, statistic = 30.046
          24) V10Wks <= 7.142857; criterion = 1, statistic = 19.078
            25) v11 <= 3.5738; criterion = 0.989, statistic = 12.966
              26)*  weights = 524 
            25) v11 > 3.5738
              27)*  weights = 853 
          24) V10Wks > 7.142857
            28)*  weights = 27 
        23) V8 > 1
          29) v12 <= 0; criterion = 1, statistic = 27.748
            30)*  weights = 38 
          29) v12 > 0
            31)*  weights = 88 
    20) V7 > 0
      32) V14 <= 0; criterion = 1, statistic = 25.564
        33) V8 <= 1; criterion = 0.98, statistic = 13.9
          34)*  weights = 115 
        33) V8 > 1
          35)*  weights = 48 
      32) V14 > 0
        36) V13 <= 2; criterion = 0.983, statistic = 11.504
          37)*  weights = 96 
        36) V13 > 2
          38)*  weights = 91 
  19) V4 > 0
    39) V8 <= 1; criterion = 1, statistic = 25.961
      40) V3 <= 0; criterion = 0.999, statistic = 17.093
        41) V14 <= 0; criterion = 0.965, statistic = 10.183
          42)*  weights = 127 
        41) V14 > 0
          43)*  weights = 480 
      40) V3 > 0
        44)*  weights = 172 
    39) V8 > 1
      45) v15 <= 0; criterion = 0.995, statistic = 14.604
        46) V9 <= 0; criterion = 0.987, statistic = 12.104
          47) v1 == {HS}; criterion = 1, statistic = 21.895
            48)*  weights = 43 
          47) v1 == {BM, CJ}
            49) v16 <= 0; criterion = 0.979, statistic = 15.049
              50)*  weights = 30 
            49) v16 > 0
              51)*  weights = 14 
        46) V9 > 0
          52)*  weights = 34 
      45) v15 > 0
        53)*  weights = 141 

我希望能够对结构有所了解;很多节点!

默认情况下,plot中的party会将每个拆分放在一个椭圆中,并为终端节点添加其他信息。但这不适合页面。

1 个答案:

答案 0 :(得分:1)

您是否尝试过增加图像尺寸?我在这里用partykit包概述了一个例子,但是它与派对包一样(我使用了派对一段时间,直到我的数据集大小开始崩溃派对):

How do I jitter the node split strings in plotting ctree output from partykit?