Digital Geography

7. April 2013

Shiny @RStudio: an analytical webapp

As i was preparing myself for getting funding for the trip to the R user conference this year in Albacete, Spain I was coming across a highlightning talk by Josh Paulson about an interactive way of using the power of R without real struggling with R as a programming language: Shiny is a cool webapp which lets the user control the application via some drop-down menus and buttons and R computes the result in the background and displays them as well on the webpage:

shiny @rstudio: a nice analytical webapp ( source )

The given examples show on one hand the power of shiny: eays GUI for an unexperienced user with sliders, buttons and so on, stong power due to the R computation engine in the background.

The installation

The installation seems quite easy as it is just expecting node.js (with npm), R and the shiny package for R. Yet it states:

Experimental quality. Use at your own risk!

So we tried to install it on our powerserver, but we had some issues according to the installation guide with the npm installation which fails with the dependencies after the nodejs installation was fine…
Despite our problems it should work like this according to the git-page of shiny for UBUNTU 12.04:

sudo apt-get update
sudo apt-get install software-properties-common python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

# Install R
sudo add-apt-repository 'deb http://cran.rstudio.com/bin/linux/ubuntu precise/'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update
sudo apt-get install r-base r-base-dev

# Install Shiny in system-wide library
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""

sudo npm install -g shiny-server

# Install Upstart script
sudo wget\
  https://raw.github.com/rstudio/shiny-server/master/config/upstart/shiny-server.conf\
  -O /etc/init/shiny-server.conf

# Create a system account to run Shiny apps
sudo useradd -r shiny
# Create a root directory for your website
sudo mkdir -p /var/shiny-server/www
# Create a directory for application logs
sudo mkdir -p /var/shiny-server/log

# Start Shiny
sudo start shiny-server

#Install examples to test
sudo cp -R /usr/local/lib/R/site-library/shiny/examples /var/shiny-server/www/

The examples

Examples are given on the websites itself and they are accompanied with various tutorials so can dive into a shiny world big style. Yet we are not sure, whether the plotting of a shapefile will be shown on screen as well. We will try it on a virtual box.

examples of shiny @RStudio ( source )

Personally I think that the examples are impressive so far. The biggest problem in distributing R to me is the “ignorance” and prejudices against open source. With shiny you will avoid this maybe, as you only use a browser. But of course the problem will arise again when the user needs to upload material for analysis like excel shets with some real operational value.

Conclusion

I think it is an interesting way to follow as using R through the web could be the inital motor to get in touch with users that likes the interfaces of SPSS…
Especially for easy day-to-day analysis in specialised departments which are not in the programming topic but need analytical results for monitoring purpose this will be an interesting tool: the advantage of fast prototyping with R and easy usage with the browser of your choice:

plotting stock exchange rates with shiny and R ( source )

  • Seek freeware experience

    whoah this weblog is great i really like studying your articles.
    Stay up the great work! You know, a lot of people are searching round for this information, you could help them greatly.