Legend
Legend

Reputation: 116780

How can I visualize hierarchical data?

I have some data like the following:

A A1 12
A A2 23
A A3 AA1 1
A A3 AA2 2
B B1 2
B B2 1

Is there a way to visualize this information in ggplot? I am looking for something like this:

   |--A1---12
   |--A2---23
A--|--A3--AA1--1
      |---AA2--2

B--|--B1---2
   |--B2---1

Any suggestions?

Upvotes: 12

Views: 4037

Answers (3)

Jens
Jens

Reputation: 2439

Check out the function sizetree() in the plotrix package.

also treemaps make allow nice visualizations, see package treemap

finally check out either the javascript library protovis or d3js, both have great possibilities for visualizing hierarchies. it is a bit tedious to get the data in there though...

Upvotes: 3

Iterator
Iterator

Reputation: 20560

Take a look at Rgraphviz, which can allow you to visualize graphs (including trees), using different schemes for your nodes.

Upvotes: 5

mitchus
mitchus

Reputation: 4877

Are you set on using ggplot? Personally, I would not process this kind of data in R since it's not really of statistical nature. I would rather write a python script to build a tree/forest, and view it using one of the many excellent graph visualization tools out there, e.g. Gephi.

Upvotes: 3

Related Questions