process=StartProcess[$SystemShell];
outputFile=FileNameJoin[{NotebookDirectory[],"output.txt"}];
ClearAll[run];
run[commands_,seconds_:2]:=Module[{},
commandSent=commands<>" > \""<>outputFile<>"\"";
WriteLine[process,commandSent];
Pause[seconds];
Import[outputFile]
];
$rDirectory="C:\\Program Files\\R\\R-3.3.0\\bin\\x64";
now runnning
run["cd \""<>$rDirectory<>"\""]
and
run["dir"]
produces the same result as running on cmd directly but running
run["R.exe"]
doesn't seem to start the R process. But if i do these directly on cmd it works.
I have used this method several times to connect to external processes but it is not working for R. Someone please help!!!
Runis for single execution while i want to keep sending a sequence of commands programmatically and retrieve results. Can you please check whether i am the only one having this problem or there is some issue? – user13892 Sep 15 '18 at 17:49RLink... – Henrik Schumacher Sep 15 '18 at 17:53RLinkcrashes for large data. And has other bugs. I want the program to run in R but queries generated programmatically since there are alot of combinations. – user13892 Sep 15 '18 at 17:55cd-ing to the directory which has the executable? – user13892 Sep 15 '18 at 17:56process=StartProcess[$SystemShell];is starting the cmd not as an admin. Do you know how to start the process as an admin? – user13892 Sep 15 '18 at 20:31Import[commandstring,"Text"], e.g.,cmdstr = "!R.exe something", thenImport[cmdstr,"Text"]– xieyn Sep 16 '18 at 01:44RLinkcrashing with large data. That should return some useful results for half of this question. – Edmund Sep 16 '18 at 12:22Importis not working with R. I had usedImportto call another external program and it worked perfectly.RunProcessworks for me, for example,RunProcess[{"c:\\Program Files\\R\\R-3.5.1\\bin\\Rscript.exe", "test.r"}, "StandardOutput"], but this may be not what you want... – xieyn Sep 16 '18 at 12:58RLinkcrashes for large data. And has other bugs." - Can you please report those? Either through the standard mechanism (tech.support), or even just via separate questions here. There are some bugs for the installation procedure, that are being dealt with, but I have not seen reports for crashing with big data transfers yet. Thanks. – Leonid Shifrin Sep 16 '18 at 20:56Import, see e.g. here for more details. If that doesn't help, I can try looking into this later. – Leonid Shifrin Sep 18 '18 at 12:36