Opening Shiny App Directly in the Default Browser

Opening Shiny App directly in the default browser

To run it using different approach to @Batanichek you can locate the executables of each of your browsers and then specify it in options which to point to, as so:

Edit:
You can find the options and its arguments in the R environment (I used RStudio) e.g. options(browser = )

Step 1: Locate where your .exe files are installed for all you browsers, then add the following:

For Chrome

options(browser = "C:/Program Files/Google/Chrome/Application/chrome.exe")

For Firefox

options(browser = "C:/Program Files/Mozilla Firefox/firefox.exe")

For IE

options(browser = "C:/Program Files/Internet Explorer/iexplore.exe")

Step 2: Run the app as always

runApp(list(ui = ui, server = server),host="192.168.xx.xx",port=5013, launch.browser = TRUE)

shiny not opening in browser from RStudio

There is a dropdown menu in RStudio, right next to Run App button, change it to Run External.

Sample Image

Or we can set launch.browser:

runApp(launch.browser = TRUE)

launch.browser If true, the system’s default web browser will be
launched automatically after the app is started. Defaults to true in
interactive sessions only. This value of this parameter can also be a
function to call with the application’s URL.

Shiny: Choose whether to run app in Window, in Viewer Pane or Externally

I was able to resolve my issue with this code:

# Create ui and server
# Set Rstudio to run external
shinyApp(ui = ui, server = server) # runs externally
options(shiny.launch.browser = .rs.invokeShinyWindowViewer)
shinyApp(ui = ui, server = server) # runs in RStudio window

possible to run RShiny app without opening an R environment?

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.



Related Topics



Leave a reply



Submit