Category Archives: Shiny

Posts referring to the Shiny framework for R

Shiny App for Polling Forums

In 2010, Crystal Palace FC were in administration and had 10 points deducted during the year. They only survived in the Championship on the last day of the season

A year ago, they started the league with three consecutive losses and were relegation favourites.

Fast forward 12 months and they are again strong tips for the drop but this time from the Premier League. Last weekend, a player who was playing non-league football not so long ago bagged the winner for their first three points of the new season

It has been quite a ride for their supporters, including myself, and has led to a significant increase in volume on the forums the supporters website,

As a Shiny developer, I thought it would be useful to have a web app which regularly polls the forums, thus saving on many link clicks to find the latest coverage – which admittedly is the usual mixture of interesting comment, lame banter and swear words

For me, the most interesting aspects as far as development is concerned are

  • Application of ‘invalidateLater’ which reactivates the function that scrapes the web pages on a proscribed time basis e.g 30 minutes, alterable by the user
  • Enactment of the progress bar, a new feature of the shiny-incubator package
  • Use of the dataTables component of the rCharts package, which allows sorting and searches

I will probably add a couple of extra features but a working version can be found here

I would definitely be interested in doing similar work for items of more general usage
so any suggestions are very welcome

More goodies from rCharts

The guys developing rCharts continue to release enhancements by the day and I have taken advantage to update a couple of Shiny apps


The CRAN download app now sports the new exporter feature so that any chart a user comes up with can be saved as a SVG vector, PNG or JPEG image or as a PDF document. In addition, there is now support for the Datatables js library so I have taken the opportunity to revamp the tables in the app. The top 10 sections now page all packages/countries (so takes a little longer to load) and also has a useful filter option

The Wikipedia Search app was initially based on ggplot but I have now added a Highchart from the rChart library. This has the benefits of providing tooltips and a zoom facility as well as the above-mentioned exporter option. Most importantly, click events are also now available for the app. For any point the user can click to obtain either the subject’s wikipedia page or the google search result for news of the subject for that particular day. So taking our favourite subject, Justin Bieber, one can see that a paricular highpoint was the 1st March 2011. Clicking on the point it shows that this was his 17th birthday when the romance with Selena Gomez was at its most intense. Some of his other peaks are for less salubrious events. It is pretty clear that this could prove a pretty useful for any journalistic research over the past five years

Hope you enjoy. There is plenty more under development

Not only CRAN downloads and Shiny … but also .. rCharts

I have been meaning for some time to get stuck into the rCharts package which provides
an interface to many Javascript graphic libraries. These offer rich charting capabilities with interactivity and a great deal of customization.


As regular readers will know, I am also interested in improved publicity for CRAN packages, although the Shiny app I developed needs a bit of attention!

So I was delighted when RStudio decided to release daily logs of downloads from their CRAN mirror. It seems as though I am not alone in this, as there have already been several blog posts including a Top 100 of 2013 with some nice graphs from Tal Galili and maps from James Cheshire and Ramnath Vaidyanathan . Of course, this is only one of about 90 CRAN mirrors so
there is no way to be sure it reflects total usage but the usual suspects top the charts

As it happens, Ramnath is the prime mover behind rCharts and he and fellow contributor, Thomas Reinholdsson, have held my hand in the development of a Shiny CRAN Downloads app. The charts included are based on the sophisticated Highcharts library which offers elegant presentation, zoom capability and interactivity including customizable tool-tips and click events, which I have used to link to the relevant package pdf.

Users can select one or more packages or countries and get a chart showing activity in terms of total downloads, rank or percent. In addition, there are tables showing both the Top Tens by week since November 2012 and record achievements in terms of ranking and downloads. Shiny, for example, achieved its highest ranking position of 70 last week as it topped the 1000 downloads from this mirror for the first time

The code, with a limited set of the data, is available as a gist. Or load shiny and runGist(’5832902′) to view

So give it a whirl and let me know what you think.

I’m planning to keep it updated each Monday

Shiny App for CRAN packages

Over the past few days, I have been introduced to a few new-to-me R packages, via some comments from the Shiny guys and the R-bloggers site. This seems a rather haphazard way of acquiring knowledge and I cannot be alone in thinking that this is not the most productive way to become aware of new/better packages. Word of mouth and occasional recommendations on sites like StackOverflow are all well and good but may be insufficient given the multitude of packages and growing user base

The CRAN site does a useful job with their summaries by Topic View but several packages I use the most e.g. ‘plyr’,'stringr’, and ‘XML appear to be absent. Perhaps a new topic or two devoted to manipulation and webscraping would help

It would be great to have a site where experts could review both new packages and revisions of the more-popular established ones. Crantastic does allow users to review and rate packages but there is a pretty low response. It also allows people to list the packages they use. This is potentially a good way of showing the most popular, and presumably most useful, packages but again the total data barely averages 1 per CRAN package. Still, better than nothing and I suggest more participation there would be helpful pending any data on actual CRAN downloads by package

As mentioned in my last post, I have been working on some CRAN stats and decided to produce a Shiny app which may help a trifle in this area. It will be regularly updated and summarizes all packages, by Topic group, as well as providing the detailed description and other details such as revision timeline by individual package. Nothing that new, but bringing info together in a different format. Please note that it takes a while to load. Hope some of you find it useful

TV shows rated by episode as a Shiny App

A few days ago there was an interesting R based article by diffuseprior on the decline and fall in the quality of The Simpsons

The author scraped results from GEOS, an online survey of TV programs, and applied the R package changepoint to offer an analysis of the show over time

This seemed a candidate for a Shiny App, as there are another gross of shows on GEOS. 24 follows a similar pattern to ‘The Simpsons’  although this well-defined decline is by no means universal


.  Although using this app multiplies the quantity of charts available, its automation precludes some of the difficult-to-accomplish, data munging done in the original post e.g excluding specials. This will cause some distortion

I have adapted diffuseprior’s code in a few respects

  1. I used the the readHTMLTable from the XML package as the data is contained in a tabular form
  2. I used ggplot for the graph rather than base plot. This took a bit more work but enabled me to  display visually the relative number of voters for each episode of a show
  3. It is now available as a Shiny App , covering 145 shows, with any new GEOS votes incorporated in real-time

The code is available as a gist 5498431