Select Page

The following is a sketch of the steps taken to bring up a working platform to host the iNZight application being developed in the Department of Statistics under the supervision if Prof. Chris Wild.

iNZight?

See https://www.stat.auckland.ac.nz/~wild/iNZight/ The application is a collection of R datasets and tools exposed through a web interface using the shiny server framework developed by the people at rstudio.com. The instance described here assumes that the open source version is being used. The iNZight project would like to expose rich statistical toolsets to users who would otherwise find tooling up difficult.

Platform

Ubuntu (desktop 12.04 LTS x64)

This also works with Ubuntu 14.04! The prepackaged shiny-server binary requires an x64 architecture, if you start with an x86, you will need to build shiny-server from source -not too arduous, but certainly more involved! NOTE. Ubuntu 14.04 comes with R 3.0.2. Do not upgrade yet! It looks like some of the iNZight stuff is not compatible with 3.1.0+, which is the version you get if you configure a cran mirror in the sources list. apt-get <…> (you may need to do an apt-cache search <..> to get the specific name)

  • gcc (4.6)
  • openssh
  • openssl
  • gdebi-core
  • curl/libcurl-dev (ssl)
  • libcairo2-dev
  • libxt-dev
  • skip this (see note above)
    sudo cp /etc/apt/sources.list /etc/apt/sources-YYYYMMDD.list
    sudo echo deb http://cran.stat.auckland.ac.nz/bin/linux/ubuntu precise/ >>/etc/apt/sources.list
    sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys E084DAB9
    sudo apt-get update
  • r-base
  • r-base-dev

Install the shiny library in R

sudo R
install.packages('shiny', repos='http://cran.rstudio.com/')
q()

OR from the command line as follows

sudo su - -c "R -e "install.packages('shiny', repos='http://cran.rstudio.com/')""
 ...

download a current version of the server software from http://www.rstudio.com/

sudo apt-get install gdebi-core
sudo gdebi shiny-server-XXXXXXXX.deb
...

At this point, shiny is now running on the machine -check by opening a web client on the box and going to http://localhost:3838/ By default, you will see either an empty ‘/’ directory, or a default shiny server document -which, will depend on how you installed it. / => /srv/shiny-server/

R (as root)

  • Packages (run R as root, then run install.packages(‘library’)) httr codetools RCurl devtools markdown
  • bleeding edge stuff In R (run as root), load the devtools library (library(‘devtools’)), then run the following install_github(‘iNZightPlots’,’iNZightVIT’)
    install_github(‘iNZightTS’,’iNZightVIT’)
    install_github(‘shiny’,’rstudio’)

The last installs the latest version of ‘shiny’ from the git repository. The work above can be written as an R script. The following can be executed from a commandline as root.

# ***********************************
# Build the iNZight platform within R
# sudo R -e "source('/path/to/me.R')"
# ***********************************

iNZightLibs <- c("shiny", "httr", "codetools", "RCurl", "devtools", "markdown")
install.packages(iNZightLibs, lib='/usr/local/lib/R/site-library', repos='http://cran.stat.auckland.ac.nz/', dependencies = TRUE)

# set the default mirror
options(repos = c(CRAN = "http://cran.rstudio.com"))

library('devtools')
install_github('iNZightPlots', 'iNZightVIT')
install_github('iNZightMR', 'iNZightVIT')
install_github('iNZightTS', 'iNZightVIT')
install_github('shiny', 'rstudio')

# the following runs the code
# from the iNZightShiny code
libs <- c("shiny", "knitr", "shinyAce", "car", "tools", "gridExtra", "markdown", "R.utils", "psych", "arm", "plyr", "reshape2", "vegan", "ggplot2", "lubridate", "wordcloud", "AlgDesign", "gpairs", "iNZightPlots", "iNZightTS","grid")

# check if all packages in libs are available
available <- suppressWarnings(sapply(libs, require, character.only=TRUE))
inst.libs <- libs[available == FALSE]
if (length(inst.libs) != 0)
{
 install.packages(inst.libs, dependencies = TRUE)
 suppressWarnings(sapply(inst.libs, require, character.only=TRUE))
}

# done

 

Environment

A group to create, delete and otherwise change material on the shiny-server

  • Make a group for “shiny users” -shiny-users
  • add users to the group!
  • sudo chgrp -R shiny-users /srv/shiny-server
  • sudo chmod -R 775 /srv/shiny-server

subfolders of shiny-server can be added with distinct permissions if required. The shiny server appears to run as root.

References

http://www.rstudio.com/shiny/server/install-opensource

Skip to toolbar