Run Shiny App from Shortcut Windows 10

允我心安 提交于 2019-11-30 20:19:38

问题


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.


回答1:


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




回答2:


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()


来源:https://stackoverflow.com/questions/42421798/run-shiny-app-from-shortcut-windows-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!