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

tables.groovy (revision 148)
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)
14
matrix.print()
15

  
16
//println "remove rows 1"
17
//matrix.removeRows([1], true)
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)
18 14
//matrix.print()
19

  
20
//println "remove cols 4"
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"
21 45
//matrix.removeCols([4], true)
22 46
//matrix.print()
23

  
24
//println "merge rows 0 1"
25
//int[] rows = [0,1]
26
//matrix.mergeRows(rows);
47
//
48
//println "reload data from test.txt"
49
//matrix.importData(new File("test.txt"))
27 50
//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"
45
matrix.removeCols([4], true)
46
matrix.print()
47

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

  
52
r.setLog(false)
51
//
52
//r.setLog(false)

Also available in: Unified diff