Shiny

What is shiny

Shiny is a set of tools that allow you to build web applications in R. It's made by the folks at Rstudio and as a consequence, Rstudio is great tool for building shiny applications. For a quick start just open in your browser; create an appropriately named project; and :

You can build your shiny app from the template that Rstudio provides. You can find lots of examples and tutorials on line. If you build a working Shiny App as an Rstudio project somewhere in your home directory, you will be able to "publish" it on the internet by simply creating a directory and a symlink. All that is described below it will take 20 seconds.

Generally, Shiny's visualization capabilities are used to give a public face to a project. There are times, however, when the Shiny App should not be public. It is possible to provide simple password access to restrict who may view the output. Email trouble@demog.berkeley.edu if you require this feature.

Headsup about installing packages:

When you are working in rstudio.demog.berkeley.edu, it is easy to use install.packages to install an R package in your own persons library. This is a fine thing to do generally BUT be aware that the instance of Rstudio that powers the shiny server will not have access to your personal library. So if your shiny app relies on a package that is not installed in the public library (that is if you had to run install.packages to get it), then alert the authorities (email trouble@demog.berkeley.edu). Or else your shiny app will fail for users who are not you.

Putting your shiny project online

The Demography Lab runs a shiny server that has read-only access to home directories. The read-only bit is for security, but the fact that the server can read your home directory (but only if you let it) means that publishing your shiny apps on line is quite simple. Here are the steps:

  1. Once only -- Create a ShinyApps directory with a link to a place where your logs should go:
    * (shiny requires a place to write logs -- even if you never read them)

  mkdir ~/ShinyApps
  chmod 755 ~/ShinyApps
  mkdir /vm/shiny-persistent/${USER}-log
  ln -s /vm/shiny-persistent/${USER}-log  ~/ShinyApps/log

  1. For each shiny App:
    * Create the App in Rstudio in a project (directory) which we'll call shinyProj for now
  • Make a symlink so that your project can be referenced from your ~/ShinyApps directory:
      cd ~/ShinyApps
      ln -s ~/path/to/shinyProj name-of-shinyproj
    
    
    • The path to shinyProj needs to start from your home directory you can use either '..' or '~' to get there
    • shinyProj represents the directory that holds the shiny project.
      • shiny project directories should have either a file in it called app.R or two files one called server.R and the other ui.R
    • name-of-shinyproj can be anything it will only affect the URL underwhich the world finds your app, but nothing else

Finding your project on line

Once you have competed the steps above, your project should run at http://shiny.demog.berkeley.edu/username where username is your username of course. Unfortunately, at present, http://shiny.demog.berkeley.edu (without a specified /username) returns an error.

Please note that your Shiny app is fully visible to the public. It is possible to restrict access to a group of viewers using username/password pairs for authentication, but setting this up requires some intervention at the system level. If you need this capability, please ask trouble@demog.berkeley.edu.