Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an exe for r code correctly

I would like to let my users use a shiny app that is stored on gist.github.com using library(shiny);runGist("xxx"). For this purpose I've created a folder that contains portable Chrome, portable R and 2 files:

1 - run.R - contains the following code:

library(shiny);runGist("xxx")

2 - VBScript that should call the run.r so the runGist will be invoked.

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

When I click the VBScript nothing happens so I guess I'm missing something, how can solve this issue?

UPDATE: after clicking the run.vbs I got a numbered file, when I opened it on Notepad++ I got the following text:

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

Listening on http://127.0.0.1:1337

When I copied http://127.0.0.1:1337 to the browser it gives what I want. So the question is how to invoke the browser with address provided in the message? - I noticed that each click gives another address.

like image 415
mql4beginner Avatar asked Jan 04 '17 09:01

mql4beginner


1 Answers

You can override default browser option, then runGist with launch.browser will just work.

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.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
like image 141
Kul-Tigin Avatar answered Sep 28 '22 17:09

Kul-Tigin