To get started make sure you have the most up to date RStudio version (menu “Help” -> “Check for Updates”) and R.
Then go ahead and install Shiny:
install.packages("shiny")
We will use another package to deploy our app to the web called shinyapps. Please install the most up to date version.
library(devtools)
install_github("rstudio/shinyapps")
Shiny makes it very easy to write your own app, but to keep things simple it does have some requirements for it to run.
To get started, within your Stat 547 course folder create a folder entitled: “Shiny-apps” and within that folder create a directory entitled “Gapminder-app”. You can do this either from your terminal window or using your graphical directory to create these folder. Each Shiny app gets its own folder. Skip here if you want to use Rstudio to help you set up your directory structure
Using the terminal (the “$” here represents your terminal prompt NOT your R console prompt) to make our folders:
$ mkdir Shiny-apps
$ cd Shiny-apps
$ mkdir Gapminder-app
$ cd Gapminder-app
Or use your RStudio files navigator to make these directories or in R:
dir.create("Shiny-apps")
dir.create("Shiny-app/Gapminder-app")
Your Stat-547 directory now probably looks something like this:
├───Stat-547
├───Amazing-homework
├───Brilliant-notes
└───Shiny-apps
└───Gapminder-app
Shiny, in its most basic form, requires only 2 files: ui.R and server.R
Making sure we are in our “Gapminder-app” directory, create an empty R script entitled ui.R and an empty R script entitled server.R
├───Stat-547
├───Amazing-homework
├───Brilliant-notes
└───Shiny-apps
└───Gapminder-app
├───ui.R
└───server.R
Your ui.R creates your user interface for your Shiny app. This is the part that controls the layout, the way you can insert images and where you specify how the user can interact with your app. Your server.R file serves up your data, reacts to the user input and contains the overall data processing “guts.”
In RStudio File menu choose: New Project > New Directory > Shiny Web Application. Choose to make a new directory in your Stat545 directory (which is under version control). This series of commands will set up a Shiny app that is based on faithful data set.
When you are ready to show you app to the world you can deploy it to the web. What are your options?
runGitHub() is a way to run an app from github using Rstudio.runGitHub() takes a few arguments, if I had a public repo in the Stat545 organization called “julia_gustavsen_shiny” and I had pushed my Gapminder app server.R and ui.R (and any other necessary files) to that repo, we could run my app using `runGitHub(“STAT545-UBC/julia_gustavsen_shiny”,subdir = “Shiny-apps/Gapminder-app/”). The subdirectory argument refers to the subdirectory in the repository.server.R or ui.R app click on the “Publish” button 
library(devtools)devtools::install_github("rstudio/shinyapps")shinyapps::deployApp('Shiny-apps/Gapminder-app') and it should deploy the app to a url under your account name (e.g. my gapminder app is here: https://jooolia.shinyapps.io/Gapminder-app/)Sys.setlocale(locale="en_US.UTF-8") on linux or mac and Sys.setlocale(locale="English") on Windows (thanks Stack Overflow) and then try setting your account info and then deploying the app again.server.R or uir.R script and then try deployment using the “Publish” button.devtools::install_github("rstudio/shinyapps") and then restart RStudio.