Why only the first definition of matrix in R code is returned?

Aug 20, 2013 at 3:38 PM
Edited Aug 20, 2013 at 3:39 PM
The problem as in subj:
A code sorts database records in table (weekdays/hours). After evaluating the R code only the initial FinTable is availiable (with zero values). I need a FinTable with processed values. How can I fix it?
engine.Evaluate(@"library(som)
DatTable<-read.table(""clipboard"", header=FALSE)
FinTable<-matrix(sample(0, 24*7, replace=TRUE), 24, 7)
DatTable[,3]<-normalize(DatTable[,3], byrow=FALSE)
for (i in 1:nrow(DatTable)){  
xAxes<-DatTable[i,1]  
yAxes<-DatTable[i,2]  
if (yAxes==0) {yAxes<-24}  
FinTable[yAxes,xAxes]<-DatTable[i,3]
}");
NumericMatrix FinTable = engine.GetSymbol("FinTable").AsNumericMatrix();
Aug 27, 2013 at 6:21 AM
Edited Aug 27, 2013 at 6:25 AM
So, I've got some clue. Because this code is inside C# code, it is indented. That leads to problems with for cycle. I didn't fixed it yet, but I suspect, that the problem is the result of specific use of curly brackets and indentation. Anyway, when I replace for cycle with direct assigments of values to created matrix, it works fine and I get a proper matrix as return.
Sep 10, 2013 at 12:28 PM
Yeah!! I've got it! The solution is to put semicolon after each statement in for loop. So, the next code will work
engine.Evaluate(@"library(som)
DatTable<-read.table(""clipboard"", header=FALSE)
FinTable<-matrix(sample(0, 24*7, replace=TRUE), 24, 7)
DatTable[,3]<-normalize(DatTable[,3], byrow=FALSE)
for (i in 1:nrow(DatTable)){  
xAxes<-DatTable[i,1] ; 
yAxes<-DatTable[i,2] ; 
if (yAxes==0) {yAxes<-24};  
FinTable[yAxes,xAxes]<-DatTable[i,3]
}");
NumericMatrix FinTable = engine.GetSymbol("FinTable").AsNumericMatrix();
Coordinator
Sep 10, 2013 at 12:43 PM
I'm sorry, I miss the discussion.

I might solve this problem in the recent changeset.
The latest source code might go without semicolons.
Sep 10, 2013 at 5:06 PM



Sent with AquaMail for Android
http://www.aqua-mail.com


On September 10, 2013 8:43:08 AM "kos59125" wrote:

From: kos59125

I'm sorry, I miss the discussion.

I might solve this problem in the recent changeset.
The latest source code might go without semicolons.
Sep 11, 2013 at 7:16 AM
Edited Sep 11, 2013 at 7:17 AM
kos59125 wrote:
I'm sorry, I miss the discussion.

I might solve this problem in the recent changeset.
The latest source code might go without semicolons.
Thanks.
Anyway, should the use of semicolons in new versions of R.NET cause error?
Coordinator
Sep 12, 2013 at 7:11 AM
Both removing and keeping semicolons may be OK. I'd appreciate it if you let me know either case (with or without semicolons) does not work.