38

Normally the shiny app opens through the inbuilt browser within R-Studio. Is it possible to open the app directly in the web browser, say Google Chrome, without going through the R-Studio.

Phil
  • 7,287
  • 3
  • 36
  • 66
Apricot
  • 2,925
  • 5
  • 42
  • 88
  • 1
    You mean something like this: `runApp(list(ui = ui, server = server),host="192.168.xxx.xx",port=80, launch.browser = T)`. as long as the app running you can access it by typing into your browser the IP address of the app (192.168.xxx.xx:80) – Pork Chop Feb 10 '16 at 09:34
  • @PorkChop Thankyou...what I meant was, when you click on the run app button in R-Studio, can the app be made to open in the default web browser. – Apricot Feb 10 '16 at 09:45

4 Answers4

52

In my Rstudio(Version 0.98.1103) i can change where run app

enter image description here

If your choose Run External its run into browser

Batanichek
  • 7,761
  • 31
  • 49
28

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)
Pork Chop
  • 28,528
  • 5
  • 63
  • 77
  • 2
    where do you provide the `options` argument/function? – theforestecologist Jul 20 '17 at 01:36
  • 1
    Since @theforestecologist asked, you put the options as it's own line, so options(browser = "C:/Program Files/Google/Chrome/Application/chrome.exe") then the following line as runApp(list(ui = ui, server = server),host="192.168.xx.xx",port=5013, launch.browser = TRUE) – Silentdevildoll Jan 23 '19 at 23:53
  • @Silentdevildoll see edit for `options(browser = )`, you can access it via R – Pork Chop Jan 24 '19 at 07:53
6

Adding to other replies here, I feel it's worth mentioning that one does not necessarily need to give the full path to the external web browser, if you're happy with the default external browser, and you're using Rstudio (i.e. basically, if your goal is not to open Rstudio's own internal browser).

For Rstudio users, the following will do:

options(shiny.launch.browser = .rs.invokeShinyWindowExternal)

You can run it at the beginning of each session when you need this, or by including this line in your ~/.Rprofile if you like this to be default behaviour, which can be conveniently done with usethis::edit_r_profile().

For more details and alternative settings, see this post.

giocomai
  • 3,043
  • 21
  • 24
  • 1
    So you can also just say: `runApp(list(ui = ui, server = server), launch.browser = .rs.invokeShinyWindowExternal)` without calling to the options() function separately – mattador Jul 20 '23 at 15:59
6

Quick answer

Replace this

shinyApp(ui = ui, server = server)

with this

shinyApp(ui = ui, server = server, options = list(launch.browser = TRUE))
stevec
  • 41,291
  • 27
  • 223
  • 311