Getting started with Shiny – R web application package

Shiny is a package for building interactive web applications to visualize and play around with data without any knowledge of JavaScript or HTML.

To get started with it, we first need to install R and within the R terminal – the shiny package. I will be using Ubuntu 12.04 as my operating environment.

Installing R

For Shiny to work, R version should be >=2.15.x. The latest version of R is 3.0.0. released in April 2013. For details on the latest version, refer Upgrading to 3.0.0.

 $ sudo add-apt-repository ppa:marutter/rrutter
 $ sudo apt-get update
 $ sudo apt-get install r-base r-base-dev

For more details on installing R, refer Installing R in Ubuntu.

If you had installed R previously and have upgraded to the version provided by the PPA, you might refer Moving to 3.0.0 on Ubuntu. Also, you need to rebuilt all the installed packages. Use

 $ sudo R
 > update.packages(checkBuilt=TRUE)

The first command opens the R terminal with super user permissions required to install packages. This process will take a while depending on the number of packages installed on your R system. If any package installation returned a non-zero exit status, install it separately by

 > install.packages('package_name') 

Installing Shiny

Once R is installed/upgraded, go to the terminal and type

 > install.packages('shiny')

Checking installation success

To check installation status for the package, first close the R terminal by Ctrl+D. This is to exit the terminal with superuser permissions. Open the R terminal by simply typing R in the Ubuntu terminal. Then, run the following commands in the newly opened R terminal:

 > library(shiny)  # To include package shiny in the session
 > runExample("01_hello")  # Running the Hello Shiny Example

This should open a browser with the Hello Shiny! example –

shiny-eg-1

That’s it! You have successfully installed Shiny and are now running your first application. To know more, go through the tutorial provided by RStudio (see Reference).

References
Shiny Tutorial
CRAN Package Shiny
RStudio IDE

Advertisements

6 thoughts on “Getting started with Shiny – R web application package

  1. Any particular reason you are running ‘R’ as a sudoer?
    When i had installed Shiny a few days back, i had faced some dependency errors and had to resolve them using ubuntu packages for the same.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s