R User Group of Milano (Italy)

Thirteen lines of code

Thanks to R-bloggers, I discovered that googleVis 0.4.7 with RStudio integration is available on CRAN.

This is great news, but wasn't this that catched my eye. At the end of the post a beautiful map shows a terrible event of the last days: the devastating typhoon track of Haiyan that hit Southeast Asia in November.

plot

It was amazing for me that this plot was created with only 13 lines of code, the following ones:

To be honest, some more break lines will increase code readibility as reported below, but it is wonderful how this plot can be drawn with so few lines of code: two lines about options (loading libraries), nine lines to import data and only one line to produce the plot (and another one to view it!).

Sometimes, also nice things are easy to be obtained.

2 comments

  1. Hi Enrico,

    That's great, but how can one adapt this visualization code to a different table? It looks like your code is mainly based on the url data.

  2. Nicola Sturaro Sommacal /

    Hi CA,
    If I really meant your question, the first part of the code contains data loading. Of course, the code is specific for the type of data and for the web page. You can re-adapt to use a different page, or substitute all with a simple read.table() if this apply to your case.

    By the way, plot can be drawn at the same way also if your data come from other sources.

    Let me know.

Trackbacks/Pingbacks

  1. Thirteen lines of code | Milano R net | R for J... - [...] Milano R net | MilanoR.net - Milano R User Group Site  [...]

Leave a Reply