Revision 479 tmp/org.txm.groovy.core/src/groovy/org/txm/test/tables.groovy

tables.groovy (revision 479)
1
//package org.txm.test
2
//
3
//import org.txm.stat.engine.r.*
4
//import org.txm.stat.engine.r.data.*
5
//
6
//def r = RWorkspace.getRWorkspaceInstance()
7
//r.setLog(true)
8
//
9
//int[][] data = [[1,2,3,4,0], [78,64,18,3,0], [2,84,7,168,0], [5,7,6,0,0], [12,4,88,1668,0], [0,0,0,0,1]]
10
//String[] lineNames = ["L1", "L2", "L3", "L4", "L5", "L6"]
11
//String[] colNames = ["C1", "C2", "C3", "C4", "C5"]
12
//
13
//MatrixImpl matrix = new MatrixImpl(data, lineNames, colNames)
1
package org.txm.test
2

  
3
import org.txm.stat.engine.r.*
4
import org.txm.stat.engine.r.data.*
5
import org.txm.statsengine.r.core.data.MatrixImpl
6

  
7
def r = RWorkspace.getRWorkspaceInstance()
8
r.setLog(true)
9

  
10
int[][] data = [[1,2,3,4,0], [78,64,18,3,0], [2,84,7,168,0], [5,7,6,0,0], [12,4,88,1668,0], [0,0,0,0,1]]
11
String[] lineNames = ["L1", "L2", "L3", "L4", "L5", "L6"]
12
String[] colNames = ["C1", "C2", "C3", "C4", "C5"]
13

  
14
MatrixImpl matrix = new MatrixImpl(data, lineNames, colNames)
15
matrix.print()
16

  
17
//println "remove rows 1"
18
//matrix.removeRows([1], true)
14 19
//matrix.print()
15
//
16
////println "remove rows 1"
17
////matrix.removeRows([1], true)
18
////matrix.print()
19
//
20
////println "remove cols 4"
21
////matrix.removeCols([4], true)
22
////matrix.print()
23
//
24
////println "merge rows 0 1"
25
////int[] rows = [0,1]
26
////matrix.mergeRows(rows);
27
////matrix.print()
28
//
29
////println "merge cols 0 1"
30
////int[] cols = [0,1]
31
////matrix.mergeCols(cols);
32
////matrix.print()
33
//
34
////println "sortByFreqs"
35
////matrix.sortByFreqs();
36
////matrix.print()
37
//
38
////println "filter fmin=100 nlines=4"
39
////matrix.filter(5,100);
40
////matrix.print()
41
//
42
//println "save data in test.txt"
43
//matrix.exportData(new File("test.txt"), ";", "\"")
44
//println "do something: delete col 4"
20

  
21
//println "remove cols 4"
45 22
//matrix.removeCols([4], true)
46 23
//matrix.print()
47
//
48
//println "reload data from test.txt"
49
//matrix.importData(new File("test.txt"))
24

  
25
//println "merge rows 0 1"
26
//int[] rows = [0,1]
27
//matrix.mergeRows(rows);
50 28
//matrix.print()
51
//
52
//r.setLog(false)
29

  
30
//println "merge cols 0 1"
31
//int[] cols = [0,1]
32
//matrix.mergeCols(cols);
33
//matrix.print()
34

  
35
//println "sortByFreqs"
36
//matrix.sortByFreqs();
37
//matrix.print()
38

  
39
//println "filter fmin=100 nlines=4"
40
//matrix.filter(5,100);
41
//matrix.print()
42

  
43
println "save data in test.txt"
44
matrix.exportData(new File("test.txt"), ";", "\"")
45
println "do something: delete col 4"
46
matrix.removeCols([4], true)
47
matrix.print()
48

  
49
println "reload data from test.txt"
50
matrix.importData(new File("test.txt"))
51
matrix.print()
52

  
53
r.setLog(false)

Also available in: Unified diff