Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Shiny App from Shortcut Windows 10

I'm trying to create a shortcut on the desktop to run a Shiny app. I am stuck on creating a batch file to execute this and after scouring the web, I still haven't been able to get it to work.

I am on Windows 10.

At the moment I have a folder on the desktop called "test" with contents:

ui.R
server.R
run.R
test.bat

Within test.bat, I have: "path to R.exe" CMD BATCH "path to my r script"

I double click on test.bat, and it flashes a window before closing.

How can I get this to work? Thank you very much in advance.

like image 397
tsouchlarakis Avatar asked Feb 23 '17 16:02

tsouchlarakis


People also ask

Can you run Shiny app locally?

You might be eager to deploy your Shiny app to a remote server. But the simplest way to run a Shiny app is to run it locally. You only need the shiny R package installed, and you can run the app in your browser.

Can you run Shiny app without R?

If you are visiting a web hosted Shiny app through your browser using the web address of the app then you don't need R installed in your computer otherwise you do. Can I make an app with R?

Can Shiny server run on Windows?

Right now Shiny Server Pro is only supported on Linux. Some customers in Windows only environments have run Shiny Server Pro by installing RedHat/CentOs or Ubuntu in a virtual machine using a technology like VMWare which works really well.


2 Answers

Probably you have solved it, but for someone who has the same question, I'm posting what worked for me. I created a .bat file like this:

"path/to/R.exe" -e "shiny::runApp('path/to/shinyAppFolder', launch.browser = TRUE)"

But I think this works as well:

"path/to/R.exe" -e "path/to/run.R"

You can always add a line with the pause command to your batch file so you can see whats going wrong with the script

Hope this helps

like image 85
Filipe Inonhe Avatar answered Oct 09 '22 10:10

Filipe Inonhe


You have to set the R working directory to the folder containing your shiny files; or explicitly specify the path in your call to runApp().

Something like this:

test.bat

"path/to/Rscript.exe" "path/to/run.R"

run.R

library(shiny)
setwd("c:/users/username/Desktop/test")
runApp()
like image 38
Hong Ooi Avatar answered Oct 09 '22 09:10

Hong Ooi