[R] Tree plot with percentages and hierarchies
Joonas Isoketo
joonas.isoketo at houston-analytics.com
Wed Jun 8 20:31:31 CEST 2016
Hi,
I have the following problem:
I want to visualize distributions of a few varibles in a specific order with a help of tree figure. Above of all is "Action x" and that happens for two (or n) reasons: "Reason 1" 50 % and "Reason 2" 50 %.
Further, "Reason 1" happens for two (or n) subreasons: "Subreason 11" (75 %) and "Subreason 12" (25 %). And further, "Subreason 11" happens for two (or n) subsubreason "SubSubreason 111" etc.
Every time when parent node splits to its childs, the sum of child node's percentages should be 100 %.
I am very pleaseful if someone could help me with this! If the plot cannot be made "on the fly", also instructions of custom tree helps (hard coded values).
Here is the test data:
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("Reason 1", "Reason 1", "Reason 1", "Reason 1", "Reason 1", "Reason 1", "Reason 1", "Reason 1", "Reason 1", "Reason 1", "Reason 2", "Reason 2", "Reason 2", "Reason 2", "Reason 2", "Reason 2", "Reason 2", "Reason 2", "Reason 2", "Reason 2")
Level_2 = c("Subreason 11", "Subreason 11", "Subreason 11", "Subreason 11", "Subreason 12", "Subreason 12", "Subreason 12", "Subreason 12", "Subreason 12", "Subreason 12", "Subreason 21", "Subreason 21", "Subreason 21", "Subreason 21", "Subreason 21", "Subreason 21", "Subreason 21", "Subreason 21", "Subreason 22", "Subreason 22")
Level_3 = c("Subsubreason 111", "Subsubreason 111", "Subsubreason 111", "Subsubreason 112", "Subsubreason 121", "Subsubreason 121", "Subsubreason 121", "Subsubreason 121", "Subsubreason 121", "Subsubreason 121", "Subsubreason 221", "Subsubreason 221", "Subsubreason 221", "Subsubreason 221", "Subsubreason 221", "Subsubreason 221", "Subsubreason 221", "Subsubreason 221", "Subsubreason 222", "Subsubreason 222")
Levels = data.frame(Level_0 = Level_0, Level_1 = Level_1, Level_2 = Level_2, Level_3 = Level_3)
Best regards,
Joonas Isoketo
[[alternative HTML version deleted]]
More information about the R-help
mailing list