r - 如何正确为 r 代码创建 exe

标签 r vbscript shiny exe

我想让我的用户使用存储在 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到浏览器它给了我想要的。
所以问题是如何使用消息中提供的地址调用浏览器? - 我注意到每次点击都会给出另一个地址。

最佳答案

您可以覆盖默认浏览器选项,然后 runGistlaunch.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/

相关文章:

html - 如何使用 R 从网站源代码/html 中抓取信息?

r - 在 R 中建立稀疏矩阵的更快方法?

sql-server - 如何从 VBScript 运行 Microsoft SQL Server 代理作业

vbscript - 使用 VBScript 确定我的时区偏移量?

r - 如何在shiny app中播放本地视频?(Windows)

r - 使用 rhandsontable 在不同格式的响应式(Reactive)数据集之间切换

r - 从数据框中手动创建 ROC 曲线

string - 如何永久禁用 data.frame 中的 stringsAsFactors=TRUE ?

asp-classic - 经典 ASP/Round() - 将 10,000+ 显示为 10K

R:rCharts 和 Shiny:人力车图不会显示