内存问题绘制datatree / chartmer

时间:2016-12-11 17:27:37

标签: r memory

我有多个小约30 * 3(问题末尾有一个这样的)数据帧,我想为其绘制树。这与我之前提出的问题有关:

 http://stackoverflow.com/questions/38347999/plot-a-decision-tree-with-r

这不会在我的mac上崩溃时进行绘图。如果我尝试将其绘制在我可以访问的集群上,我无法打开所需的XML显示。如果我使用substr作为1个字符的标签,它会绘制,但这完全没有信息。直接使用chartmer执行此操作具有相同的问题。 任何语言解决方案都会非常受欢迎,我最后想要一个体面的图表。

`dat<-structure(list(from = c(1L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 
4L, 4L, 5L, 5L, 5L, 5L, 208L, 205L, 248L, 249L, 85L, 214L, 219L, 
215L, 6L, 6L, 172L, 181L, 172L, 103L), to = structure(c(105L, 
180L, 191L, 202L, 115L, 112L, 158L, 159L, 241L, 121L, 126L, 1L,    
122L, 213L, 78L, 87L, 254L, 254L, 254L, 254L, 254L, 254L, 254L, 
254L, 78L, 6L, 254L, 254L, 254L, 254L), .Label = c("0", "10", 
"100", "101", "102", "103", "104", "105", "106", "107", "108", 
"109", "11", "111", "112", "113", "114", "115", "116", "117", 
"118", "119", "12", "120", "121", "122", "123", "124", "125", 
"126", "127", "128", "129", "13", "130", "131", "132", "133", 
"134", "135", "136", "137", "138", "139", "14", "140", "141", 
"142", "143", "144", "145", "146", "147", "148", "149", "15", 
 "151", "152", "153", "154", "155", "156", "158", "159", "16", 

&#34; 160&#34;,&#34; 161&#34;,&#34; 162&#34;,&#34; 163&#34;,&#34; 165&#34;,&# 34; 166&#34;,&#34; 167&#34;,&#34; 168&#34;,&#34; 169&#34;,    &#34; 17&#34;,&#34; 170&#34;,&#34; 171&#34;,&#34; 172&#34;,&#34; 173&#34;,&#34; 174& #34;,&#34; 176&#34;,&#34; 177&#34;,&#34; 178&#34;,     &#34; 179&#34;,&#34; 18&#34;,&#34; 180&#34;,&#34; 181&#34;,&#34; 182&#34;,&#34; 184& #34;,&#34; 185&#34;,&#34; 186&#34;,&#34; 187&#34;,     &#34; 188&#34;,&#34; 189&#34;,&#34; 19&#34;,&#34; 190&#34;,&#34; 192&#34;,&#34; 193& #34;,&#34; 194&#34;,&#34; 195&#34;,&#34; 196&#34;,      &#34; 197&#34;,&#34; 198&#34;,&#34; 199&#34;,&#34; 2&#34;,&#34; 20&#34;,&#34; 200& #34;,&#34; 201&#34;,&#34; 202&#34;,&#34; 203&#34;,&#34; 204&#34;,     &#34; 205&#34;,&#34; 206&#34;,&#34; 207&#34;,&#34; 208&#34;,&#34; 209&#34;,&#34; 21& #34;,&#34; 211&#34;,&#34; 212&#34;,&#34; 213&#34;,     &#34; 214&#34;,&#34; 215&#34;,&#34; 216&#34;,&#34; 217&#34;,&#34; 218&#34;,&#34; 219& #34;,&#34; 22&#34;,&#34; 220&#34;,&#34; 221&#34;,     &#34; 222&#34;,&#34; 223&#34;,&#34; 224&#34;,&#34; 225&#34;,&#34; 226&#34;,&#34; 227& #34;,&#34; 228&#34;,&#34; 229&#34;,&#34; 23&#34;,     &#34; 230&#34;,&#34; 231&#34;,&#34; 232&#34;,&#34; 233&#34;,&#34; 234&#34;,&#34; 235& #34;,&#34; 236&#34;,&#34; 237&#34;,&#34; 238&#34;,    &#34; 239&#34;,&#34; 24&#34;,&#34; 240&#34;,&#34; 241&#34;,&#34; 242&#34;,&#34; 243& #34;,&#34; 244&#34;,&#34; 245&#34;,&#34; 246&#34;,    &#34; 247&#34;,&#34; 248&#34;,&#34; 249&#34;,&#34; 25&#34;,&#34; 250&#34;,&#34; 251& #34;,&#34; 252&#34;,&#34; 253&#34;,&#34; 254&#34;,     &#34; 255&#34;,&#34; 256&#34;,&#34; 257&#34;,&#34; 258&#34;,&#34; 259&#34;,&#34; 26& #34;,&#34; 260&#34;,&#34; 261&#34;,&#34; 262&#34;,      &#34; 263&#34;,&#34; 264&#34;,&#34; 27&#34;,&#34; 28&#34;,&#34; 29&#34;,&#34; 3& #34;,&#34; 30&#34;,&#34; 31&#34;,&#34; 32&#34;,&#34; 33&#34;,     &#34; 34&#34;,&#34; 35&#34;,&#34; 36&#34;,&#34; 37&#34;,&#34; 38&#34;,&#34; 39& #34;,&#34; 4&#34;,&#34; 40&#34;,&#34; 41&#34;,&#34; 42&#34;,&#34; 43&#34;,     &#34; 44&#34;,&#34; 45&#34;,&#34; 46&#34;,&#34; 47&#34;,&#34; 48&#34;,&#34; 49& #34;,&#34; 5&#34;,&#34; 50&#34;,&#34; 51&#34;,&#34; 52&#34;,&#34; 53&#34;,     &#34; 54&#34;,&#34; 55&#34;,&#34; 56&#34;,&#34; 57&#34;,&#34; 58&#34;,&#34; 59& #34;,&#34; 6&#34;,&#34; 60&#34;,&#34; 61&#34;,&#34; 62&#34;,&#34; 63&#34;,     &#34; 64&#34;,&#34; 65&#34;,&#34; 66&#34;,&#34; 67&#34;,&#34; 68&#34;,&#34; 69& #34;,&#34; 7&#34;,&#34; 70&#34;,&#34; 71&#34;,&#34; 72&#34;,&#34; 73&#34;,     &#34; 74&#34;,&#34; 75&#34;,&#34; 76&#34;,&#34; 77&#34;,&#34; 78&#34;,&#34; 79& #34;,&#34; 8&#34;,&#34; 80&#34;,&#34; 81&#34;,&#34; 82&#34;,&#34; 83&#34;,     &#34; 84&#34;,&#34; 85&#34;,&#34; 86&#34;,&#34; 89&#34;,&#34; 9&#34;,&#34; 91& #34;,&#34; 92&#34;,&#34; 93&#34;,&#34; 94&#34;,&#34; 95&#34;,&#34; 96&#34;,     &#34; 97&#34;,&#34; 98&#34;,&#34; 99&#34;,&#34;结束&#34;),类=&#34;因素&#34;),nme = c(&#34; Cardi&#34;,     &#34; Cyano&#34;,&#34; Synco&#34;,&#34; Short&#34;,&#34; Sever&#34;,&#34; Profo&#34;,&#34; Newbo& #34;,&#34; Newbo&#34;,     &#34; Prod&#34;,&#34; #####&#34;,&#34; #####&#34;,&#34; #####&#34;,&#34 ;差&#34;,&#34; Syndr&#34;,&#34; Prema&#34;,     &#34; May&#34;,&#34; Conge&#34;,&#34; Conge&#34;,&#34; Conge&#34;,&#34; Conge&#34;,&#34; Hypog&#34;,&#34; Vasov&#34;,     &#34; Ortho&#34;,&#34; Conge&#34;,&#34; Down&#39;&#34;,&#34; Turne&#34;,&#34; Conge&#34;,& #34; Conge&#34;,&#34; Conge&#34;,     &#34; Coarc&#34;)),。Name = c(&#34; from&#34;,&#34; to&#34;,&#34; nme&#34;),row.names = c( NA,     -30L),class =&#34; data.frame&#34;)     库(data.tree)

dat$nme<-substr(as.character(dat$nme), 1, 5 ) 

subTree<-FromDataFrameNetwork(dat)

SetNodeStyle(subTree , style = "filled,rounded", shape = "box", fontname =              "helvetica", label = function(node) node$nme, tooltip = "name")

plot(subTree ) `

1 个答案:

答案 0 :(得分:0)

标签功能中有拼写错误(nme而不是名称)。此外,您的标签功能是默认设置,因此您可以将其全部保留。以下作品:

SetNodeStyle(subTree, style = "filled,rounded", shape = "box", fontname = "helvetica")