Skip to content
Prev 361586 / 398502 Next

Tree plot with percentages and hierarchies

Hi,

super, that was exactly what I needed! Thanks!

Best regards,

Joonas Isoketo 



-----Alkuper?inen viesti-----
L?hett?j?: Jim Lemon [mailto:drjimlemon at gmail.com] 
L?hetetty: 9. kes?kuutata 2016 1:40
Kopio: Joonas Isoketo <joonas.isoketo at houston-analytics.com>; r-help at r-project.org
Aihe: Re: [R] Tree plot with percentages and hierarchies

Hi Joonas,
It is easy to display hierarchic classification using either the plot.dendrite or sizetree functions (plotrix). At the moment, they will only display counts, not percentages. It would not be too difficult to reprogram either one to display percentages. Here are examples with shortened category names (you'll see why):

Level_0 = c("Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X", "Action X")
Level_1 = c("R1", "R1", "R1", "R1", "R1", "R1", "R1", "R1", "R1", "R1", "R2", "R2", "R2", "R2", "R2", "R2", "R2", "R2", "R2", "R2")
Level_2 = c("Subr11", "Subr11", "Subr11", "Subr11", "Subr12", "Subr12", "Subr12", "Subr12", "Subr12", "Subr12", "Subr21", "Subr21", "Subr21", "Subr21", "Subr21", "Subr21", "Subr21", "Subr21", "Subr22",
"Subr22")
Level_3 = c("Subsubr111", "Subsubr111", "Subsubr111", "Subsubr112", "Subsubr121", "Subsubr121", "Subsubr121", "Subsubr121", "Subsubr121", "Subsubr121", "Subsubr221", "Subsubr221", "Subsubr221", "Subsubr221", "Subsubr221", "Subsubr221", "Subsubr221", "Subsubr221", "Subsubr222",
"Subsubr222")

Levels = data.frame(Level_0 = Level_0, Level_1 = Level_1, Level_2 = Level_2, Level_3 = Level_3)

library(plotrix)
plot.dendrite(Levels)
sizetree(Levels)

Jim
On Thu, Jun 9, 2016 at 6:03 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
Message-ID: <DB5PR0101MB15896EBC098E1D7D689220EEC25F0@DB5PR0101MB1589.eurprd01.prod.exchangelabs.com>
In-Reply-To: <CA+8X3fUpOBZsb2FjjcS_1tFT4QoV9vsX5An0gEO421OC+F+MWg@mail.gmail.com>