Showing posts with label RJSONIO. Show all posts
Showing posts with label RJSONIO. Show all posts
googleVis 0.6.1 on CRAN
We released googleVis version 0.6.1 on CRAN last week. The update fixes issues with setting certain options, following the switch from
New to googleVis? The package provides an interface between R and the Google Charts Tools, allowing you to create interactive web charts from R without uploading your data to Google. The charts are displayed by default via the R internal help browser.
To lean more see the examples of googleVis charts on CRAN and read the introduction vignette.
RJSONIO to jsonlite. ![]() |
| Screen shot of some of the Google Charts |
To lean more see the examples of googleVis charts on CRAN and read the introduction vignette.
Clone all your gists locally with R
I really like gists as a quick way to include more lengthly code snippets into my blog posts. However, I am not a git user as such, and so I was quite concerned when I noticed that all my gists on this blog had vanished after Christmas. I suppose this was a result of Github's downtime on December 22nd.
Thankfully an email to the support guys at Github resolved the issue within a few hours. Still, I thought it might be a good idea to download my gists locally.
I can see all my gists as a JSON file online here:
Thus, I downloaded the file and thanks to the RJSONIO package I was able to clone all my gists locally with a few lines of R:
Thankfully an email to the support guys at Github resolved the issue within a few hours. Still, I thought it might be a good idea to download my gists locally.
I can see all my gists as a JSON file online here:
https://api.github.com/users/MYUSERLOGIN/gistsThus, I downloaded the file and thanks to the RJSONIO package I was able to clone all my gists locally with a few lines of R:
Setting the initial view of a motion chart in R
Following on from my article about accessing and plotting World Bank data with R I want to talk about how to change the initial view of a motion chart.
Over the last couple of weeks I have been asked a view times how to do this. For instance Stephen O'Grady wanted to create a motion chart, which shows initially a line chart, rather than a bubble chart.
Changing the initial settings of a motion chart is actually quite easy, if you know how to. The trick is to use the
As a case study I will use the World Bank data set and try to do some homework given by Duncan Temple Lang in his course on introduction to statistical computing course. Duncan asked his students to query the World Bank data base to create a line chart, which would show the number of internet users per 1000 in Africa over time. Further, he would like to see a legend next to the chart to identify which country is which and tooltips for each curve to identify the country.
A motion chart, displayed as a line chart, would do the trick.
Okay, getting the data is easy, thanks to the WDI package, or via a direct download, and so it is to create a motion chart with bubbles. Interactively I can change the bubble chart into a line chart, I can select some countries and change the y-axis to log-scale. However, when I reload the page I am back to square one: a bubble chart. So the idea is to pass the changed chart settings on to the initial plot. I find those settings, of the current view, as a string in the advanced tab of the settings window. I click on the wrench symbol in the bottom right hand corner of a motion chart to access this window.
Next I copy this string and paste it into the
Here is an example, where I pre-selected Sierra Leone and Seychelles (countries with the lowest and highest number of internet users) together with Africa, North Africa and Sub-Saharan Africa (all income levels). You find the R code below to replicate the plot.
What does the data tell you? Play around with the graph, e.g. change it to a column graph, deselect all countries and change the y-axes to linear again, and hit the play button. How could we improve the plot?
Over the last couple of weeks I have been asked a view times how to do this. For instance Stephen O'Grady wanted to create a motion chart, which shows initially a line chart, rather than a bubble chart.
Changing the initial settings of a motion chart is actually quite easy, if you know how to. The trick is to use the
state argument in the list of options of gvisMotionChart.As a case study I will use the World Bank data set and try to do some homework given by Duncan Temple Lang in his course on introduction to statistical computing course. Duncan asked his students to query the World Bank data base to create a line chart, which would show the number of internet users per 1000 in Africa over time. Further, he would like to see a legend next to the chart to identify which country is which and tooltips for each curve to identify the country.
A motion chart, displayed as a line chart, would do the trick.
Okay, getting the data is easy, thanks to the WDI package, or via a direct download, and so it is to create a motion chart with bubbles. Interactively I can change the bubble chart into a line chart, I can select some countries and change the y-axis to log-scale. However, when I reload the page I am back to square one: a bubble chart. So the idea is to pass the changed chart settings on to the initial plot. I find those settings, of the current view, as a string in the advanced tab of the settings window. I click on the wrench symbol in the bottom right hand corner of a motion chart to access this window.
![]() |
| Screen shot the settings window of a motion chart |
Next I copy this string and paste it into the
state argument of the options list. Note the line break at the beginning and at the end of the state string in the example. Alternatively I can add \n to both side of the state string. Here is an example, where I pre-selected Sierra Leone and Seychelles (countries with the lowest and highest number of internet users) together with Africa, North Africa and Sub-Saharan Africa (all income levels). You find the R code below to replicate the plot.
What does the data tell you? Play around with the graph, e.g. change it to a column graph, deselect all countries and change the y-axes to linear again, and hit the play button. How could we improve the plot?
30 Sept 2011
08:00
googleVis
,
initial view
,
Motion Chart
,
options
,
R
,
RJSONIO
,
Tutorials
,
WDI
,
World Bank
Accessing and plotting World Bank data with R
Over the past couple of days I played around with the data sets of the World Bank, and I have to admit that I am blown away by it. It is amazing, to see what is available on their web site and it is worth visiting their Data Visualisation Tools page. It is fantastic that they provide an API to their data. They have used it to build an iPhone App which is pretty cool. You can have the world's data in your pocket.
In this post I will show you how we can access data from the World Bank in R. As an example we create a motion chart, in the Hans Rosling style, as you find it on the Google Public Data Explorer site, which also uses data from the World Bank. Doing this, should give us the confidence that we understand the World Bank's interface. You can find this example as demo
So let's try to replicate the initial plot of the Google Public Data Explorer, which shows fertility rate against life expectancy for each country from 1960 to today, whereby the countries are represented as bubbles, with the size reflecting the population and the colour the region.
In this post I will show you how we can access data from the World Bank in R. As an example we create a motion chart, in the Hans Rosling style, as you find it on the Google Public Data Explorer site, which also uses data from the World Bank. Doing this, should give us the confidence that we understand the World Bank's interface. You can find this example as demo
WorldBank as part of the googleVis package from version 0.2.10 onwards.So let's try to replicate the initial plot of the Google Public Data Explorer, which shows fertility rate against life expectancy for each country from 1960 to today, whereby the countries are represented as bubbles, with the size reflecting the population and the colour the region.
25 Sept 2011
15:41
Google Public Data Explorer
,
googleVis
,
Motion Chart
,
R
,
RJSONIO
,
Tutorials
,
World Bank

