我想让我的用户使用存储在 gist.github.com 上的 Shiny 应用程序使用 library(shiny);runGist("xxx")
.
为此,我创建了一个文件夹,其中包含可移植 Chrome、可移植 R 和 2 个文件:
1 - run.R
- 包含以下代码:
library(shiny);runGist("xxx")
2 - 应该调用 run.r 以便调用 runGist 的 VBScript。Randomize
CreateObject("Wscript.Shell").Run "R-Portable\App\R-Portable\bin\R.exe CMD BATCH --vanilla --slave run.R" & " " & RND & " ", 0, False
当我单击 VBScript 时没有任何 react ,所以我想我错过了一些东西,如何解决这个问题?更新:单击 run.vbs 后,我得到了一个编号文件,当我在 Notepad++ 上打开它时,我得到以下文本:
Downloading https://gist.github.com/#############/download
NULL
[1] TRUE
Listening on http://127.0.0.1:1337
当我复制 http://127.0.0.1:1337
到浏览器它给了我想要的。所以问题是如何使用消息中提供的地址调用浏览器? - 我注意到每次点击都会给出另一个地址。
最佳答案
您可以覆盖默认浏览器选项,然后 runGist
与 launch.browser
只会工作。
运行.R
#Assuming your portable Chrome's relative path is "Chrome\Application\chrome.exe"
options(browser = normalizePath("Chrome\\Application\\chrome.exe"));
library(shiny);
runGist("xxx", launch.browser = TRUE);
run.vbs
Set Fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")
'specify CD to start commands from script's parent folder
WshShell.CurrentDirectory = Fso.GetParentFolderName(WScript.ScriptFullName)
'Start the command as hidden and don't wait
WshShell.Run "R-Portable\App\R-Portable\bin\R.exe CMD BATCH --vanilla --slave run.R NUL", 0, False
关于r - 如何正确为 r 代码创建 exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41459979/