我有多个小的大约30*3 (一个在问题的结尾)数据,我想要绘制一棵树。这与我先前提出的一个问题有关:
http://stackoverflow.com/questions/38347999/plot-a-decision-tree-with-r这并不是在我的mac上不崩溃的情况下策划的。如果我尝试将其绘制到我可以访问的集群上,则无法打开所需的XML显示。如果我用一个substr来表示一个字符的标签,它就会显示出来,但这是完全没有信息的。直接用图表做这件事也有同样的问题。任何语言解决方案都将是最受欢迎的,我只是想要一个像样的图表在最后。
`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", "160“、"161”、"162“、"163”、"165“、"166”、"167“、"168”、"169“、"17”、"170“、"171”、"172“、"173”、"174“、"176”、"177“、"178”、"179“、"18”、"180“、"181”、"182“、"184”、"185","186“、"187”、"188“、"189”、"19“、"190”、"192“、"193”、"194“、"195”、"196“、"197”、"198“、"199”、"2“、"20”、"200“、"201”、"202“、"203”、"204“、"205”、"206“、"207”、"208","209“、"21”、"211“、"212”、"213“、"214”、"215“、"216”、"217“、"218”、"219“、"22”、"220“、"221”、"222“、"223”、"224“、"225”、"226“、"227”、"228“、"229”、"23“、"230”、"231","232“、"233”、"234“、"235”、"236“、"237”、"238“、"239”、"24“、"240”、"241“、"242”、"243“、"244”、"245“、"246”、"247“、"248”、"249“、"25”、"250“、"251”、252、"253“、"254","255“、"256”、"257“、"258”、"259“、"26”、"260“、"261”、"262“、"263”、"264“、"27”、"28“、"29”、"3“、"30”、"31“、"32”、"33“、"34”、"35“、"36”、"37“、"38”、"39","4“、"40”、"41“、"42”、"43“、"44”、"45“、"46”、"47“、"48”、"49“、"5”、"50“、"51”、"52“、"53”、"54“、"55”、"56“、"57”、"58“、"59”、"6“、"60”、"61","62“、"63”、"64“、"65”、"66“、"67”、"68“、"69”、"7“、"70”、"71“、"72”、"73“、"74”、"75“、"76”、"77“、"78”、"79“、"8”、"80“、"81”、"82“、"83”、"84","85“、"86”、"89“、"9”、"91“、"92”、"93“、"94”、"95“、"96”、"97“、"98”、"99“、”结束“、类=”因素“)、nme = c("Cardi”、"Cyano“、"Synco”、"Short“、"Sever”、"Profo“、"Newbo”、"Newbo“、”Prod“、"#####“、"Poor”、"Syndr“、"Prema”、"May h“、"Conge”、“Syndr”、"Vasov“、"#####”、"Conge“、”Down“、"Turne”、"Conge“、”Coarc“),.Names = c("from","to","nme"),row.names = c(NA,-30L),class = "data.frame")库(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 ) `发布于 2016-12-12 08:26:05
标签函数中有一个错误(nme而不是name)。此外,label函数是默认的,因此您可以将其全部排除在外。以下工作:
SetNodeStyle(subTree, style = "filled,rounded", shape = "box", fontname = "helvetica")
https://stackoverflow.com/questions/41088937
复制相似问题