Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / scripts / prototypes / tables.groovy @ 1000

History | View | Annotate | Download (1.2 kB)

1
package org.txm.scripts.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)
19
//matrix.print()
20

    
21
//println "remove cols 4"
22
//matrix.removeCols([4], true)
23
//matrix.print()
24

    
25
//println "merge rows 0 1"
26
//int[] rows = [0,1]
27
//matrix.mergeRows(rows);
28
//matrix.print()
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)