0
votes

I have multiple small approx 30*3 (one such at end of question) dataframes that I want to plot a tree for. This is related to a previous question I asked:

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

This does not plot without crashing on my mac. If I try instead to plot it on the cluster I have access to, I can not open the required XML display. If I use a substr for the label of 1 character, it plots, but that is entirely uninformative. Doing this directly with diagrammer has the same issue. Any language solution would be most appreciated, I just want a decent graph in the end.

`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", "End"), class = "factor"), nme = c("Cardi", "Cyano", "Synco", "Short", "Sever", "Profo", "Newbo", "Newbo", " Prod", "#####", "#####", "#####", "Poor ", "Syndr", "Prema", "May h", "Conge", "Conge", "Conge", "Conge", "Hypog", "Vasov", "Ortho", "Conge", "Down'", "Turne", "Conge", "Conge", "Conge", "Coarc")), .Names = c("from", "to", "nme"), row.names = c(NA, -30L), class = "data.frame") library(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
Perhaps use ExcelEd Heal
I would but I have lots of such data frames so need a more efficient way to do it.cianius

1 Answers

0
votes

You have a typo in the label function (nme instead of name). Also, your label function is the default, so you can leave it out alltogether. The following works:

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