Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

possible to run RShiny app without opening an R environment?

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?

like image 567
Green Demon Avatar asked Apr 08 '13 17:04

Green Demon


People also ask

Can you run a Shiny app without R?

You can create a standalone shiny app, that runs on computers WITHOUT needing to install R nor any library.

Is R Shiny open source?

Easy web applications in RShiny is an open source R package that provides an elegant and powerful web framework for building web applications using R. Shiny helps you turn your analyses into interactive web applications without requiring HTML, CSS, or JavaScript knowledge.


3 Answers

I know this is an old discussion, but it might help someone knowing this can be done now. You can create a standalone shiny app, that runs on computers WITHOUT needing to install R nor any library. There is a relatively simple way of doing it (currently I've done it only for Windows users, but something for MacOS should be around too), following these detailed steps: http://www.r-bloggers.com/deploying-desktop-apps-with-r/ .Other option could be uploading the app on the Shiny server.

like image 101
NicolazziE Avatar answered Oct 08 '22 15:10

NicolazziE


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.

like image 35
Spacedman Avatar answered Oct 08 '22 16:10

Spacedman


You can now use the RInno package for this type of thing. To get setup:

install.packages("RInno")
require(RInno)
RInno::install_inno()

Then you just need to call two functions to setup an installation framework:

create_app(app_name = "myapp", app_dir = "path/to/myapp")
compile_iss()

If you would like to include R, add include_R = TRUE to create_app:

create_app(app_name = "myapp", app_dir = "path/to/myapp", include_R = TRUE)

It defaults to include shiny, magrittr and jsonlite, so if you are using other packages like ggplot2 or plotly, just add them to the pkgs argument. You can also include GitHub packages to the remotes argument:

create_app(
    app_name = "myapp", 
    app_dir  = "path/to/myapp"
    pkgs     = c("shiny", "jsonlite", "magrittr", "plotly", "ggplot2"),
    remotes  = c("talgalili/installr", "daattali/shinyjs"))

If you are interested in other features, check out FI Labs - RInno

like image 33
Jonathan Hill Avatar answered Oct 08 '22 16:10

Jonathan Hill