Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (1 invisible), 672 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Running R from a zorro script. #459138
04/24/16 19:09
04/24/16 19:09
Joined: Apr 2016
Posts: 10
J
JackSturgeon Offline OP
Newbie
JackSturgeon  Offline OP
Newbie
J

Joined: Apr 2016
Posts: 10
All,

I try to run Zorro 1.42 with the laters R 3.2.5 on windows 10.

To do this, I installed both programms and added the right path to the zorro.ini file.

RTermPath = "c:\Program Files\R\R-3.1.3\bin\i386\Rterm.exe"

When I run the RTest script in Zorro it fails.

Did anybody see this behavior? How can I fix this?

Thanks in advance.

Jack

Re: Running R from a zorro script. [Re: JackSturgeon] #459150
04/25/16 04:54
04/25/16 04:54
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Your RTermPath does not lead to R 3.2.5. Perhaps you have updated your R installation, but not your Zorro.ini file?

Re: Running R from a zorro script. [Re: boatman] #459152
04/25/16 05:33
04/25/16 05:33
Joined: Apr 2016
Posts: 10
J
JackSturgeon Offline OP
Newbie
JackSturgeon  Offline OP
Newbie
J

Joined: Apr 2016
Posts: 10
That is a correct observation.

I first installed the newest R and the newest Zorro. Then I tried to configure the R bridge with the RTermPath variable in the Zorro.ini file.

Because that did not work, I thought it might be the R version. Because Zorro.ini points to the older version I downloaded that and installed it. So I really have the older R release installed and I am pointing to it correctly.

Jack.

Re: Running R from a zorro script. [Re: JackSturgeon] #459156
04/25/16 08:02
04/25/16 08:02
Joined: Apr 2016
Posts: 10
J
JackSturgeon Offline OP
Newbie
JackSturgeon  Offline OP
Newbie
J

Joined: Apr 2016
Posts: 10
In addition to the previous...

I tried to install the newest zorro and R on another machine. I changed the line for RTermPath into the following:

RTermPath = "C:\Program Files\R\R-3.2.5\bin\i386\Rterm.exe"

It still does not work. Is there a way to get some logging out of the zorro process to see what happens?

Jacco.

Re: Running R from a zorro script. [Re: JackSturgeon] #459160
04/25/16 12:56
04/25/16 12:56
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
R 3.2.5 works fine with Zorro. Here's a script that produces some diagnostics at start:

Code:
function main()
{
	if(!g->sRTermPath) {
		printf("R path missing! ");
		return;
	}
	if(!file_date(g->sRTermPath)) {
		printf("%s not found! ",g->sRTermPath);
		return;
	}
	string Cmd = strf("%s  --no-save",g->sRTermPath);
	printf(Cmd); 
	hR = RInit_(Cmd,2);
	if(!hR) {
		printf("Can't initialize RTerm! ");
		return;
	}
	Rx("rm(list = ls());"); // clear the workspace
	
	var vecIn[5],vecOut[5];
	int i;
	for(i=0; i<5; i++) 
		vecIn[i] = i;
	
	Rset("Rin",vecIn,5);
	Rx("Rout <- Rin * 10");
	Rv("Rout",vecOut,5);
	
	if(!Rrun()) 
		printf("Error - R session aborted!");
	else {
		printf("\nReturned: ");
		for(i=0; i<5; i++) 
			printf("%.0f ",vecOut[i]);
	}
}


Re: Running R from a zorro script. [Re: jcl] #459163
04/25/16 13:50
04/25/16 13:50
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Windows sometimes goes strange ways. I often face problems with applications installed in "\Programm Files" because of special NTFS settings. I installed R directly in C:\\R\... and had no problems anymore.

Re: Running R from a zorro script. [Re: Sphin] #459168
04/25/16 15:00
04/25/16 15:00
Joined: Apr 2016
Posts: 10
J
JackSturgeon Offline OP
Newbie
JackSturgeon  Offline OP
Newbie
J

Joined: Apr 2016
Posts: 10
All,

First of all, thanks for all the support. I think there is something wrong when zorro tries to run R with the command Rrun.

I slightly modified the print statements in the script above and I added the r.h include. It now looks like:
#include <r.h>

function main()
{
if(!g->sRTermPath) {
printf("R path missing! ");
return;
}
if(!file_date(g->sRTermPath)) {
printf("%s not found! ",g->sRTermPath);
return;
}
string Cmd = strf("Command : %s --no-save",g->sRTermPath);
printf(Cmd);
hR = RInit_(Cmd,2);
if(!hR) {
printf("Can't initialize RTerm! ");
return;
}

Rx("rm(list = ls());"); // clear the workspace

var vecIn[5],vecOut[5];
int i;
for(i=0; i<5; i++)
vecIn[i] = i;

Rset("Rin",vecIn,5);
Rx("Rout <- Rin * 10");
Rv("Rout",vecOut,5);

if(!Rrun())
printf("\nError - R session aborted!");
else {
printf("\nReturned: ");
for(i=0; i<5; i++)
printf("%.0f ",vecOut[i]);
}
}

The output is:
Zorro 1.42.2 Trading Automaton
Made with Gamestudio by oP group 2015

testREnv compiling.................
Command : C:\R\bin\x64\Rterm.exe --no-save
Error - R session aborted!

So the script aborts when running the Rrun() command.

Just to make sure, I now installed R in C:\R as shown in the output. My RTermPath is:

RTermPath = "C:\R\bin\x64\Rterm.exe"

Both the x64 and the i386 do not work.

Jacco.

Re: Running R from a zorro script. [Re: JackSturgeon] #459169
04/25/16 15:31
04/25/16 15:31
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Ok, so R was correctly initialized, but then terminated for some unknown reason. Can you replace the line

Rx("rm(list = ls());");

with

RExecute(hR,"rm(list = ls());");
printf("\n%s",RLastOutput(hR));
if(!RIsRunning(hR)) {
printf("\nR stopped!");
return;
} else
printf("\nR still running...");

and let me know what it prints?

Re: Running R from a zorro script. [Re: jcl] #459177
04/26/16 07:50
04/26/16 07:50
Joined: Apr 2016
Posts: 10
J
JackSturgeon Offline OP
Newbie
JackSturgeon  Offline OP
Newbie
J

Joined: Apr 2016
Posts: 10
Hi Chief, ;-)

I changed the script as you indecated and it prints the following:


testREnv compiling.................
Command : C:\R\bin\x64\Rterm.exe --no-save

R stopped!

I tried to run the complete command from a cmd and this start up Rterm.exe
perfectly. I get the prompt and can leave with q() as expected.

From the zorro script Rterm.exe seems to stop as printed by the zorro script.

I hope you have a suggestion of what to do.

Re: Running R from a zorro script. [Re: JackSturgeon] #459182
04/26/16 08:59
04/26/16 08:59
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Ok, now it becomes a little more complicated since you need to download a tool, the Debug Viewer. You can download it from many places, f.i. here:

https://technet.microsoft.com/en-us/sysinternals/debugview.aspx

Start it with default options. "Capture Win32" should be on. Now start the test script again and post here what the debug viewer prints out.

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1