RealMatrix { public double[][] getColumns(int[] columns) { for (int i = 0; i < columns.length; i++) { if (columns[i] == 0) { throw new ExecutionException("getColumns: Column number can not be zero. R indices start from 1"); } } code.clearOnline(); code.addRCode(this.HashString + "<- t(" + this.name + "[,c("); for (int i = 0; i < columns.length; i++) { code.addRCode(String.valueOf(columns[i])); if (i != columns.length - 1) { code.addRCode(","); } } code.addRCode(")])"); rcaller.runAndReturnResultOnline(this.HashString); int[] dims = rcaller.getParser().getDimensions(this.HashString); return (rcaller.getParser().getAsDoubleMatrix(this.HashString, dims[0], dims[1])); } RealMatrix(RService service);  RealMatrix(String pathToR, String name); RCaller getRCaller(); void setData(double[][] data); int[] getDimensions(); double[][] getData(); double[] getColumn(int column); double[][] getColumns(int[] columns); double[] getRow(int row); double[][] getRows(int[] rows); double getDeterminant(); RealMatrix getInverse(); double[] getDiagonal(); double getTrace(); RealMatrix getTranspose(); RealMatrix product(double[][] another); RealMatrix product(RealMatrix another); RealMatrix sum(double[][] another); RealMatrix sum(RealMatrix another); RealMatrix productWithScaler(double scaler); RealMatrix subtract(double[][] another); RealMatrix subtract(RealMatrix another); double[] getEigenValues(); RealMatrix getEigenVectors(); SVD getSVD();  }
@Test public void testGetColumns() { System.out.println("getColumns"); double[][] result = rm.getColumns(new int[]{1, 2}); assertEquals(1.0, result[0][0], delta); assertEquals(2.0, result[0][1], delta); assertEquals(4.0, result[1][0], delta); assertEquals(9.0, result[1][1], delta); }