Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

Commented Unassigned: Access Violation Exception after extended run of t.test loop [43]

$
0
0
My code runs just fine with one data set but fails at the same point each time a different data set is run. Two different arrays are created in a loop through a large data set using "engine.CreateNumericVector(arGroup1Intensities)" and "engine.CreateNumericVector(arGroup2Intensities)". The data sets are comprised of 207 and 623 members (doubles), respectively. After 223 iterations, I get an error "attempted to read or write protected memory." After going back and checking, it appears that the first array was created fine (207 members), but was reduced to just 1 member when the second array was created. Any suggestions how to fix this?

The "engine" is an REngine that is created at the top of the loop with "using (REngine engine = REngine.CreateInstance("Test")". The creation and checking of arrays is accomplish within the loop with:

vGroup1 = engine.CreateNumericVector(arGroup1Intensities);
Console.WriteLine(vGroup1.Length);
vGroup2 = engine.CreateNumericVector(arGroup2Intensities);
Console.WriteLine(vGroup2.Length);
engine.SetSymbol("group1", vGroup1);
engine.SetSymbol("group2", vGroup2);
GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList();

Comments: Tried to reproduce on an x86 Win7 with R 3.0.0. Could not repro the issue. Need contact rcharvey. ``` Random r = new Random(0); int N = 500; int n1 = 207; int n2 = 623; var arGroup1Intensities = new double[N][]; var arGroup2Intensities = new double[N][]; for (int i = 0; i < N; i++) { arGroup1Intensities[i] = new double[n1]; arGroup2Intensities[i] = new double[n2]; for (int j = 0; j < n1; j++) arGroup1Intensities[i][j] = r.NextDouble(); for (int j = 0; j < n2; j++) arGroup2Intensities[i][j] = r.NextDouble(); } var res = new GenericVector[N]; NumericVector vGroup1, vGroup2; for (int i = 0; i < N; i++) { vGroup1 = engine.CreateNumericVector(arGroup1Intensities[i]); Console.WriteLine(vGroup1.Length); vGroup2 = engine.CreateNumericVector(arGroup2Intensities[i]); Console.WriteLine(vGroup2.Length); engine.SetSymbol("group1", vGroup1); engine.SetSymbol("group2", vGroup2); GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList(); res[i] = testResult; } ```

Viewing all articles
Browse latest Browse all 1634

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>