Search code examples
rplotmodelingdecision-tree

ctree plot decision tree in party package in R , terminal node occurs some weird numbers - issue?


I came across something really odd.. and I couldn't figured it out why..

I use the same code here below :

library(party)
r_tree <- ctree(readingSkills$nativeSpeaker ~ readingSkills$age + 
                 readingSkills$shoeSize + readingSkills$shoeSize + 
                 readingSkills$score,data = readingSkills)
plot(r_tree,type = "simple")
r_tree

two week ago I got normal graph .. but today my terminal nodes have some odd numbers in them like showing in this picture below.. I have tried to restarted my PC , uninstalled the packet , reinstall again and again , but it still not working.. enter image description here Just wondering if anyone see the same issue , or what have I done wrong , or how can I fix this ?

Thanks


Solution

  • This is a bug caused by package "partykit". If you'll reopen R from start or do:

    detach("package:partykit", unload=TRUE) and run

    library(party)
    r_tree <- ctree(readingSkills$nativeSpeaker ~ readingSkills$age + 
                      readingSkills$shoeSize + readingSkills$shoeSize + 
                      readingSkills$score,data = readingSkills)
    plot(r_tree,type = "simple")
    

    You'll get the normal plot enter image description here

    But if you'll library the "partykit" package again and rerun the same code, you''ll get that nonsense plot again

    library(partykit)
    r_tree <- ctree(readingSkills$nativeSpeaker ~ readingSkills$age + 
                      readingSkills$shoeSize + readingSkills$shoeSize + 
                      readingSkills$score,data = readingSkills)
    plot(r_tree,type = "simple")
    

    enter image description here