[R] Build a matrix using JRI

Francois EHRENMANN Francois.EHRENMANN at igh.cnrs.fr
Fri Dec 22 09:10:57 CET 2006


Hi everyone

I'm a new user of R and JRI for a project (debian + eclipse + Java + JRI).

I need to build a matrix from datas and i proceed like this :

First step :  create the  matrix (Rengine re)
  re.idleEval("A <- mat.or.vec(10,40)",true);

Second Step : feed the structure
  re.idleEval("A[1,1] <- 39",true);
  re.idleEval("A[1,2] <- 10",true);
  re.idleEval("A[1,3] <- 5",true);
  ...
  re.idleEval("A[10,40] <- 16",true);

I want finaly to obtain the matrix result, passing these datas to R :
  REXP x = re.idleEval("A", true);
and i make this command to see results :
  Supervisor.trace(this, x.toString());

and i have as output :

[REAL* (39.0, 10.0, 5.0, 24.0, 30.0, 5.0, 9.0, 16.0, 0.0, 0.0, 4.0, 4.0, 
2.0, 4.0, 4.0, 4.0, 2.0, 2.0, 0.0, 0.0, 3.0, 3.0, 2.0, 1.0, 3.0, 3.0, 
2.0, 3.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 4.0, 4.0, 2.0, 1.0, 0.0, 0.0, 
1.0, 1.0, 2.0, 1.0, 3.0, 3.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 1.0, 1.0, 
2.0, 2.0, 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 8.0, 3.0, 1.0, 
0.0, 0.0, 2.0, 2.0, 0.0, 1.0, 2.0, 0.0, 2.0, 3.0, 0.0, 0.0, 4.0, 4.0, 
0.0, 2.0, 2.0, 0.0, 1.0, 2.0, 0.0, 0.0, 3.0, 3.0, 0.0, 2.0, 2.0, 0.0, 
3.0, 4.0, 0.0, 0.0, ... (300 more values follow))]

Passing my datas to R (using R in a console), i obtain this output that 
i want to have using java and JRI but it doesn't work :

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,]   39    4    3    2    1    4    2    2    4     3     1     2     2
[2,]   10    4    3    2    1    4    2    2    4     3     1     5     0
[3,]    5    2    2    4    2    1    0    0    0     0     0     0     0
[4,]   24    4    1    4    1    1    2    1    2     2     3     1     2
[5,]   30    4    3    4    3    2    2    2    2     2     1     3     2
[6,]    5    4    3    4    3    2    8    0    0     0     0     0     0
[7,]    9    2    2    2    2    1    3    2    1     3     0     0     0
[8,]   16    2    3    1    2    1    1    3    2     4     2     1     4
[9,]    0    0    0    0    0    0    0    0    0     0     0     0     0
[10,]    0    0    0    0    0    0    0    0    0     0     0     0     0
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] 
[,25]
[1,]     4     2     1     4     1     4     1     1     2     1     
2     2
[2,]     0     0     0     0     0     0     0     0     0     0     
0     0
[3,]     0     0     0     0     0     0     0     0     0     0     
0     0
[4,]     1     1     3     2     4     2     1     4     2     4     
4     4
[5,]     1     3     2     3     1     2     1     1     3     2     
4     2
[6,]     0     0     0     0     0     0     0     0     0     0     
0     0
[7,]     0     0     0     0     0     0     0     0     0     0     
0     0
[8,]     2     4     4     4    11     0     0     0     0     0     
0     0
[9,]     0     0     0     0     0     0     0     0     0     0     
0     0
[10,]     0     0     0     0     0     0     0     0     0     0     
0     0
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] 
[,37]
[1,]     3     1     2     1     1     3     2     4     2     1     
4     2
[2,]     0     0     0     0     0     0     0     0     0     0     
0     0
[3,]     0     0     0     0     0     0     0     0     0     0     
0     0
[4,]     3     0     0     0     0     0     0     0     0     0     
0     0
[5,]     1     4     2     4     4     4     0     0     0     0     
0     0
[6,]     0     0     0     0     0     0     0     0     0     0     
0     0
[7,]     0     0     0     0     0     0     0     0     0     0     
0     0
[8,]     0     0     0     0     0     0     0     0     0     0     
0     0
[9,]     0     0     0     0     0     0     0     0     0     0     
0     0
[10,]     0     0     0     0     0     0     0     0     0     0     
0     0
     [,38] [,39] [,40]
[1,]     4     4     4
[2,]     0     0     0
[3,]     0     0     0
[4,]     0     0     0
[5,]     0     0     0
[6,]     0     0     0
[7,]     0     0     0
[8,]     0     0     0
[9,]     0     0     0
[10,]     0     0     0

Is possible to obtain this format above using java and jri ? if yes, 
what i have to use in the jri package ?

Thank you very much to all

Cheers

François

-- 
François Ehrenmann - IE cdd

Equipe IMGT (Marie-Paule LEFRANC),
the international ImMunoGeneTics information system®
http://imgt.cines.fr
IMGT, LIGM, IGH, UPR CNRS 1142, 141 rue de la Cardonille
34396 Montpellier Cedex 5 FRANCE
Tel: +33 (0)4 99 61 99 28 - Fax: +33 (0)4 99 61 99 01
e-mail: Francois.Ehrenmann at igh.cnrs.fr



More information about the R-help mailing list