Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Table, Org Chart & Tree Map

In the seventh part of our series we are going to learn about the features of some interesting types of charts. More specifically we will talk about Table, Org Chart and Tree Map.

Read the examples below to understand the logic of what we are going to do and then test yous skills with the exercise set we prepared for you. Lets begin!

Answers to the exercises are available here.

Package

As you already know, the first thing you have to do is install and load the googleVis package with:
install.packages("googleVis") library(googleVis)

NOTE: The charts are created locally by your browser. In case they are not displayed at once press F5 to reload the page.

Table

It is quite simple to create a Table with googleVis. We will use the “Stock” dataset.
Look at the example below to create a simple table:
TableC <- gvisTable(Stock) plot(TableC)

Exercise 1

Create a list named “TableC” and pass to it the “Stock” dataset as a table. HINT: Use gvisTable().

Exercise 2

Plot the the table. HINT: Use plot().

Table with pages

options=list(page='enable')

Exercise 3

Add pages to the table you just created and plot it. HINT: Use list().

Org chart

It is quite simple to create an Org Chart with googleVis. We will use the “Regions” dataset. You can see the variables of your dataset with head().
Look at the example below to create a simple Org Chart:
OrgC <- gvisOrgChart(Regions ) plot(OrgC)

Learn more about using GoogleVis in the online course Mastering in Visualization with R programming. In this course you will learn how to:

• Work extensively with the GoogleVis package and its functionality
• Learn what visualizations exist for your specific use case
• And much more

Exercise 4

Create a list named “OrgC” and pass to it the “Regions” dataset as an org chart. HINT: Use gvisOrgChart().

Exercise 5

Plot the the org chart. HINT: Use plot().

Dimensions

You can adjust the dimensions of the org chart with these options:
options=list(width=600, height=250, size='large')

Exercise 6

Adjust the dimensions of your org chart. Set height to 300, width to 550 and size to medium and plot it.

Tree Map

It is quite simple to create a Tree Map with googleVis. We will use the “Regions” dataset.
Look at the example below to create a simple Tree Map:
TreeC <- gvisTreeMap(Regions) plot(TreeC)

Exercise 7

Create a list named “TreeC” and pass to it the “Regions” dataset as an org chart. HINT: Use gvisTreeMap().

Exercise 8

Plot the the tree map. HINT: Use plot().

You can decide tha dependents variables of your dataset by selecting it. In the example above the dependent variable was “Val”. To choose “Fac” follow the example:
TreeC <- gvisTreeMap(Regions, "Region", "Parent", "Fac") plot(TreeC)

Exercise 9

Set “Fac” as your dependent variable, plot the tree map and see the difference.

Font size

Obviously you can change the font size of your tree map simply with:
options=list(fontSize=10)

Exercise 10

Set the size of your font to 20 and plot your tree map. HINT: Use fontSize.