possible to run RShiny app without opening an R environment?

Green Demon picture Green Demon · Apr 8, 2013 · Viewed 25k times · Source

Currently I have a R shiny app, to run it I open up RStudio and execute

setwd("C:/Users/Me/Desktop/R/ShinyProject2")
library(shiny)
......
runApp()

From a R script located in my directory.

I am sending the app for review purposes to a co-workers who doesn't know how to use R.

So I'm just wondering ... Is there an easy way to write an executable that directly opens the UI without having to click open R studio and execute the codes?

Answer

Spacedman picture Spacedman · Apr 8, 2013

RStudio != R

There is a simple command-line interface to R, which you can run on Windows by running R.exe in the bin folder of your R installation.

There's also Rscript.exe, which can run an expression or a script file. For example:

C:\Program Files\R\R-2.15.2\bin\RScript -e hist(runif(1000))

will (given the right paths) create a PDF file with a histogram in it.

So,

  • your co-worker needs an R installation
  • you need that installation to have all the packages to run shiny
  • or you add a bunch of install.packages() lines to your code
  • you need to give them a folder with your shiny code
  • you add a windows .BAT file for them to click
  • they run that, it calls Rscript.exe which starts the shiny package you gave them

Or get it hosted on the RStudio guys' public shiny server, but then we can all see it.