如何正确创建r代码的exe

mql*_*ner 12 vbscript exe r shiny

我想,让我的用户使用一个闪亮的应用程序,存储在gist.github.com使用library(shiny);runGist("xxx").为此,我创建了一个包含便携式Chrome,便携式R和2个文件的文件夹:

1 - run.R- 包含以下代码:

library(shiny);runGist("xxx")
Run Code Online (Sandbox Code Playgroud)

2 - 应该调用run.r的VBScript,以便调用runGist.

Randomize
CreateObject("Wscript.Shell").Run "R-Portable\App\R-Portable\bin\R.exe CMD BATCH --vanilla --slave run.R" & " " & RND & " ", 0, False
Run Code Online (Sandbox Code Playgroud)

当我点击VBScript时没有任何反应所以我想我错过了什么,怎么能解决这个问题呢?

更新:点击run.vbs后我得到了一个编号文件,当我在Notepad ++上打开它时,我得到了以下文字:

Downloading https://gist.github.com/#############/download
NULL
[1] TRUE

Listening on http://127.0.0.1:1337
Run Code Online (Sandbox Code Playgroud)

当我复制http://127.0.0.1:1337到浏览器时,它给出了我想要的东西.那么问题是如何使用消息中提供的地址调用浏览器? - 我注意到每次点击都会给出另一个地址.

Kul*_*gin 5

您可以覆盖默认浏览器选项,然后runGist使用launch.browser即可.

run.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 Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)