Tuesday, 22 April 2014

Notes from the Tokyo R User Group meeting, 17 April 2014

Last Thursday I had the pleasure to attend the Tokyo R user group meeting. And what a fun meeting it was! Over 40 R users had come together in central Tokyo. Yohei Sato, who organises the meetings, allowed me to talk a little about the recent developments of the googleVis package.


Thankfully all talks were given in English:

Following the meeting the user group had booked a pub around the corner for a few drinks and some food. Brilliant!

Delicious chicken steaks and rice porridge

The next morning, as I woke up in on the 23rd floor of hotel in Shinjuku I felt that my bed was moving. I am sure it was the earthquake, but what a weird feeling it was with a little hangover.

Tuesday, 15 April 2014

googleVis 0.5.1 released on CRAN

GoogleVis 0.5.1 was released on CRAN yesterday.


New Features

Changes

  • The help files of gvis charts no longer show all their options, instead a link to the online Google API documentation is given.
  • Updated googleVis demo
  • All googleVis output will be displayed in your default browser. In previous versions of googleVis output could also be viewed in the preview pane of RStudio. This feature is no longer available with the current version of RStudio, but is likely to be introduced again with the release of RStudio version 0.99 or higher.
I will discuss the new features in more detail at the R user group meetings in Tokyo this Thursday and in Cologne, 23 May.

Tuesday, 8 April 2014

Annotation charts and histograms with googleVis

After my posts on timeline, Sankey and calendar charts, this will be the last to introduce new chart types of the developer version of googleVis. Today I will give examples for the new annotation charts and histograms.

Annotation charts

Annotation charts have been part of the Google Chart tools for a long time and googleVis as well. However, in the past only a flash based version was available (gvisAnnotatedTimeLine in googleVis). With the new Google Charts Tools version also a HTML5 version was released. In googleVis it is integrated as gvisAnnotationChart. It works in exactly the same way as the Flash based version, so here is an example.



For the R code below to run you will require the developer version (≥ 0.5.0-4) of googleVis from GitHub and R ≥ 3.0.2.

Histograms

Histograms are a new chart type in Google Chart Tools API - not so in R. Still, it is nice to know that one can create those now as well.


For more information and installation instructions see the googleVis project site and Google documentation.

Session Info

R version 3.0.3 (2014-03-06)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base     

other attached packages:
[1] googleVis_0.5.0-4

loaded via a namespace (and not attached):
[1] RJSONIO_1.0-3 tools_3.0.3 

Tuesday, 1 April 2014

Calendar charts with googleVis

My little series of posts about the new googleVis charts continues with calendar charts.

Google's calendar charts are still in beta, but they provide already a nice heat map visualisation of calendar year data. The current development version of googleVis supports this new function via gvisCalendar. Here is an example displaying daily stock price data.


For the code below to run you will require the developer version (≥ 0.5.0-4) of googleVis from GitHub and R ≥ 3.0.2.

I suppose the biggest current drawback is that the colours of the cells cannot be defined by the user. However, this should change with future versions of the Google Chart Tools. For more information and installation instructions see the googleVis project site and Google documentation.

Interestingly, the calendar chart looks very similar to the visualisation R. Wicklin and R. Allison from SAS used for the winning poster at the Data Expo 2009. Paul Bleicher created a function in R, based on lattice that creates a very similar output. You may recall David Smith's blog post about this.



Session Info

R version 3.0.3 (2014-03-06)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] grid stats graphics grDevices utils datasets  methods  
[8] base     

other attached packages:
[1] googleVis_0.5.0-4 chron_2.3-45 lattice_0.20-24  

loaded via a namespace (and not attached):
[1] RJSONIO_1.0-3 tools_3.0.3

Tuesday, 25 March 2014

Sankey diagrams with googleVis

Sankey diagrams are great for visualising flows from one set of data values to another. Although named after Irish Captain Matthew Henry Phineas Riall Sankey, who used this type of diagram in 1898 to show the energy efficiency of a steam engine, the best know Sankey diagram is probably Charles Minard's Map of Napoleon's Russian Campaign of 1812, which he actually produced in 1869.

Thomas Rahlf: Datendesign mit R

The above example from Thomas Rahlf's book Datendesign mit R shows that Minard's plot can be reproduced with base graphics in R. Aaron Berdanier posted in 2010 the SankeyR function and January Weiner published the river plot package on CRAN that allows users to create static Sankey charts as well.

Interactive Sankey diagram can be generated with rCharts and now also with googleVis (version >= 0.5.0). For my a first example I use UK visitor data from VisitBritain.org. The following diagram visualises the flow of visitors in 2012; where they came from and which parts of the UK they visited. This example illustrates the key concept already. I need a data frame with three columns that explains the flow of data from a source to a target and the strength or weight of the connection.




My next example uses a graph data set that I visualise in the same way again, but here I start to play around with the various parameters of the Google API.




As stated by Google, the Sankey chart may be undergoing substantial revisions in future Google Charts releases.

For more information and installation instructions see the googleVis project site and Google documentation.

Session Info

R version 3.0.3 (2014-03-06)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets  methods  
[7] base     

other attached packages:
[1] googleVis_0.5.0-4 igraph_0.7.0     

loaded via a namespace (and not attached):
[1] RJSONIO_1.0-3 tools_3.0.3 

Monday, 24 March 2014

Tuesday, 18 March 2014

Timeline charts with googleVis

Last year at the Google I/O conference Mitchell Foley presented new developments of the Google Chart Tools API and one of the new features he mentioned were timeline charts (about 6 min into the talk).



Timeline charts are a great way of visualising different dates/events over time and are now also supported by googleVis from version 0.5.0 onwards (currently only available from GitHub). Here is an example, showing classroom allocation in the afternoon. The exact times and durations are given when you hover over the bars.



I can swap around the bar and row labels to show the rooms by languages:



Here is another example, inspired by Jason Bryer's timeline package, showing the US presidents and UK prime ministers during World War II. For gvisTimeline I have to remove the line breaks in Jason's data.



And finally a more complex example from the Google Chart Tools API documentation showing the terms of the first US presidents with various options set to change the colours and fonts: