Index: tmp/org.txm.r/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- tmp/org.txm.r/.settings/org.eclipse.jdt.core.prefs	(revision 0)
+++ tmp/org.txm.r/.settings/org.eclipse.jdt.core.prefs	(revision 219)
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6

Property changes on: tmp/org.txm.r/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/.classpath
===================================================================
--- tmp/org.txm.r/.classpath	(revision 0)
+++ tmp/org.txm.r/.classpath	(revision 219)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry exported="true" kind="lib" path="REngine.jar"/>
+	<classpathentry exported="true" kind="lib" path="RserveEngine.jar"/>
+	<classpathentry exported="true" kind="lib" path="colt-1.2.0.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Property changes on: tmp/org.txm.r/.classpath
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.r/META-INF/MANIFEST.MF	(revision 0)
+++ tmp/org.txm.r/META-INF/MANIFEST.MF	(revision 219)
@@ -0,0 +1,47 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: R Core
+Bundle-SymbolicName: org.txm.r
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.txm.utils;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: cern.clhep,
+ cern.colt,
+ cern.colt.bitvector,
+ cern.colt.buffer,
+ cern.colt.function,
+ cern.colt.list,
+ cern.colt.list.adapter,
+ cern.colt.map,
+ cern.colt.matrix,
+ cern.colt.matrix.bench,
+ cern.colt.matrix.doublealgo,
+ cern.colt.matrix.impl,
+ cern.colt.matrix.linalg,
+ cern.colt.matrix.objectalgo,
+ cern.jet.math,
+ cern.jet.random,
+ cern.jet.random.engine,
+ cern.jet.random.sampling,
+ cern.jet.stat,
+ cern.jet.stat.quantile,
+ corejava,
+ hep.aida,
+ hep.aida.bin,
+ hep.aida.ref,
+ org.rosuda.REngine,
+ org.rosuda.REngine.Rserve,
+ org.rosuda.REngine.Rserve.protocol,
+ org.txm.stat,
+ org.txm.stat.data,
+ org.txm.stat.engine.r,
+ org.txm.stat.engine.r.data,
+ org.txm.stat.engine.r.rcolt,
+ org.txm.stat.utils
+Bundle-ClassPath: REngine.jar,
+ RserveEngine.jar,
+ .,
+ colt-1.2.0.jar

Property changes on: tmp/org.txm.r/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/REngine.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.r/REngine.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.r/.project
===================================================================
--- tmp/org.txm.r/.project	(revision 0)
+++ tmp/org.txm.r/.project	(revision 219)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.txm.r</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Property changes on: tmp/org.txm.r/.project
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/RserveEngine.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.r/RserveEngine.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.r/src/org/txm/stat/ConnectToRserve.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/ConnectToRserve.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/ConnectToRserve.java	(revision 219)
@@ -0,0 +1,60 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate:$
+// $LastChangedRevision:$
+// $LastChangedBy:$ 
+//
+package org.txm.stat;
+import org.rosuda.REngine.REXP;
+import org.rosuda.REngine.RList;
+import org.rosuda.REngine.Rserve.RConnection;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConnectToRserve.
+ */
+class ConnectToRserve {
+	
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String args[]) {
+		try {
+			RConnection c = new RConnection();
+			String userhome = System.getProperty("user.home"); //$NON-NLS-1$
+			RList ret = c.eval("source('"+userhome+"/Bureau/R/Rdata')").asList(); //$NON-NLS-1$ //$NON-NLS-2$
+			
+			System.out.println("source ret : "+ret.get(1)); //$NON-NLS-1$
+			System.out.println(ret);
+			
+			REXP ret2 = c.eval("print(lexicaltable)"); //$NON-NLS-1$
+			System.out.println("lexicaltable :"+ret2); //$NON-NLS-1$
+		}
+		catch(Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+}
\ No newline at end of file

Property changes on: tmp/org.txm.r/src/org/txm/stat/ConnectToRserve.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/rcolt/package.html
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/rcolt/package.html	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/rcolt/package.html	(revision 219)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Converting colt data structure into data structure suited for the R language (mainly vectorized version of matrix).</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/rcolt/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/rcolt/RColt.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/rcolt/RColt.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/rcolt/RColt.java	(revision 219)
@@ -0,0 +1,197 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r.rcolt;
+
+import cern.colt.function.IntIntDoubleFunction;
+import cern.colt.matrix.DoubleMatrix2D;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Method for transformation of colt matrix into various array.
+ * 
+ * @author sloiseau
+ * 
+ */
+public final class RColt {
+
+	/**
+	 * Double matrix2 d2 int int array.
+	 *
+	 * @param matrix the matrix
+	 * @return the int[][]
+	 */
+	public final static int[][] doubleMatrix2D2IntIntArray(DoubleMatrix2D matrix) {
+		int rows = matrix.rows();
+		int columns = matrix.columns();
+		int[][] values = new int[rows][columns];
+		for (int row = rows; --row >= 0;) {
+			int[] currentRow = values[row];
+			for (int column = columns; --column >= 0;) {
+				currentRow[column] = (int) matrix.getQuick(row, column);
+			}
+		}
+		return values;
+		// final IntIntDoubleFunction fun = new CreateIntIntArray(matrix.rows(),
+		// matrix.columns());
+		// matrix.forEachNonZero(fun);
+		// return ((CreateIntIntArray)fun).getIntIntArray();
+	}
+
+	/**
+	 * Double matrix2 d2 double double array.
+	 *
+	 * @param matrix the matrix
+	 * @return the double[][]
+	 */
+	public final static double[][] doubleMatrix2D2DoubleDoubleArray(
+			DoubleMatrix2D matrix) {
+		matrix.trimToSize();
+		return matrix.toArray();
+	}
+
+	/*
+	 * public final static int[][] intMatrix2D2IntIntArray (IntMatrix2D matrix)
+	 * { matrix.trimToSize(); return matrix.toArray(); }
+	 */
+
+	/**
+	 * Transform a Colt {@link DoubleMatrix2D} into an array of <code>int</code>
+	 * .
+	 * 
+	 * The value of the matrix are stored by column (the values of the first
+	 * column, then the values of the second column, etc.)
+	 *
+	 * @param matrix the matrix
+	 * @return an array of <code>int</code>
+	 * @todo use {@link DoubleMatrix2D#trimToSize()} and
+	 * {@link DoubleMatrix2D#toArray()}
+	 */
+	public final static int[] doubleMatrix2D2IntArray(DoubleMatrix2D matrix) {
+		final IntIntDoubleFunction fun = new CreateIntArray(matrix.rows(),
+				matrix.columns());
+		matrix.forEachNonZero(fun);
+		return ((CreateIntArray) fun).getIntArray();
+	}
+
+	// public final static REXP DoubleMatrix2D2REXP(DoubleMatrix2D matrix,
+	// Rengine engine, String varName) {
+	// final IntIntDoubleFunction fun = new CreateIntIntArray(matrix.rows(),
+	// matrix.columns());
+	// matrix.forEachNonZero(fun);
+	// int[][] m = ((CreateIntIntArray)fun).getIntIntArray();
+	// engine.assign(varName, m);
+	// return ((CreateIntIntArray)fun).getIntIntArray();
+	// }
+
+	/**
+	 * The Class CreateIntIntArray.
+	 */
+	static class CreateIntIntArray implements IntIntDoubleFunction {
+
+		/** The array. */
+		private final int[][] array;
+
+		/**
+		 * Instantiates a new creates the int int array.
+		 *
+		 * @param rows the rows
+		 * @param columns the columns
+		 */
+		public CreateIntIntArray(int rows, int columns) {
+			array = new int[rows][columns];
+			for (int i = 0; i < array.length; i++) {
+				for (int j = 0; j < array[i].length; j++) {
+					array[i][j] = 0;
+				}
+			}
+		}
+
+		/* (non-Javadoc)
+		 * @see cern.colt.function.IntIntDoubleFunction#apply(int, int, double)
+		 */
+		@Override
+		public double apply(int row, int col, double value) {
+			array[row][col] = (int) value;
+			return value;
+		}
+
+		/**
+		 * Gets the int int array.
+		 *
+		 * @return the int int array
+		 */
+		public int[][] getIntIntArray() {
+			return array;
+		}
+	}
+
+	/**
+	 * The Class CreateIntArray.
+	 */
+	static class CreateIntArray implements IntIntDoubleFunction {
+
+		/** The array. */
+		private final int[] array;
+		
+		/** The rows. */
+		private final int rows;
+
+		/**
+		 * Instantiates a new creates the int array.
+		 *
+		 * @param rows the rows
+		 * @param columns the columns
+		 */
+		public CreateIntArray(int rows, int columns) {
+			array = new int[rows * columns];
+			for (int i = 0; i < array.length; i++) {
+				array[i] = 0;
+			}
+			this.rows = rows;
+		}
+
+		/* (non-Javadoc)
+		 * @see cern.colt.function.IntIntDoubleFunction#apply(int, int, double)
+		 */
+		@Override
+		public double apply(int row, int col, double value) {
+			array[(col * rows) + row] = (int) value;
+			return value;
+		}
+
+		/**
+		 * Gets the int array.
+		 *
+		 * @return the int array
+		 */
+		public int[] getIntArray() {
+			return array;
+		}
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/rcolt/RColt.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/StartRserve.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/StartRserve.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/StartRserve.java	(revision 219)
@@ -0,0 +1,288 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2015-06-15 15:29:16 +0200 (Mon, 15 Jun 2015) $
+// $LastChangedRevision: 2989 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r;
+
+import java.io.File;
+
+import org.rosuda.REngine.Rserve.RConnection;
+import org.txm.Messages;
+import org.txm.utils.OSDetector;
+import org.txm.utils.SystemProxyDetector;
+import org.txm.utils.StreamHog;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Helper class that consumes output of a process. In addition, it filter output
+ * of the REG command on Windows to look for InstallPath registry entry which
+ * specif ies the location of R.
+ * 
+ * @author RServe library
+ */
+
+/**
+ * simple class that start Rserve locally if it's not running already - see
+ * mainly <code>checkLocalRserve</code> method. It spits out quite some
+ * debugging outout of the console, so feel free to modif y it for your
+ * application if desired.
+ * <p>
+ * <i>Important:</i> All applications should shutdown every Rserve that they
+ * started! Never leave Rserve running if you started it after your application
+ * quits since it may pose a security risk. Inform the user if you started an
+ * Rserve instance.
+ */
+public class StartRserve {
+
+	/** shortcut to <code>launchRserve(cmd, "--no-save --slave", "--no-save --slave", false)</code>. */
+	public static Process Rserveprocess;
+
+	/**
+	 * Launch rserve.
+	 *
+	 * @param cmd the cmd
+	 * @param options 
+	 * @return true, if successful
+	 */
+	protected static boolean launchRserve(String cmd, int port, boolean debug, String rArgs, String rServeArgs) {
+		if (new File(cmd).exists() && !new File(cmd).isDirectory()
+				&& new File(cmd).canExecute())
+			return launchRserve(cmd,
+					"--no-save --slave --encoding utf8 "+rArgs, "--RS-encoding utf8 --no-save --slave --encoding utf8 "+rServeArgs, port, debug); //$NON-NLS-1$ //$NON-NLS-2$
+		return false;
+	}
+
+	/**
+	 * attempt to start Rserve. Note: parameters are <b>not</b> quoted, so avoid
+	 * using any quotes in arguments
+	 *
+	 * @param cmd command necessary to start R
+	 * @param rargs arguments are are to be passed to R
+	 * @param rsrvargs arguments to be passed to Rserve
+	 * @param debug the debug
+	 * @return <code>true</code> if Rserve is running or was successfully
+	 * started, <code>false</code> otherwise.
+	 */
+	protected static boolean launchRserve(String cmd, String rargs,
+			String rsrvargs, int port, boolean debug) {
+		//System.out.println("LAUNCH R SERVER "+cmd+" "+port+" "+debug);
+		try {
+			String[] cmdline = null;
+			// FIXME: don't forget to remove this Window dedicated code if we manage to use http_proxy command line argument
+			boolean isWindows = false;
+			
+			// Windows OS
+			if (OSDetector.isFamilyWindows()) {
+				isWindows = true; /* Windows startup */
+				
+				
+				// TODO: old tests for setting proxy in R
+				//Windows : set --internet2 option to manage proxy if any
+				
+//				// set Proxy configuration using Eclipse RCP stored values
+//				String proxy_conf = "";
+//				ProxyConf conf = new ProxyConf(RWorkspace.getRWorkspaceInstance());
+//				if (conf.mustSetProxyConfiguration()) {
+//					proxy_conf = "http_proxy="+conf.getHttpProxyUrl();
+//					rsrvargs += " "+proxy_conf; // add the http_proxy parameter
+//					Log.info("Run Rserve with proxy configuration: "+proxy_conf);
+//				}
+				
+				cmdline = new String[] {
+						cmd,
+						rargs, 
+						"-e", //$NON-NLS-1$
+						"library(Rserve);Rserve(" //$NON-NLS-1$ 
+						+ (debug ? "TRUE" : "FALSE")  //$NON-NLS-1$ //$NON-NLS-2$
+						+ ",port=" + port + "" //$NON-NLS-1$ //$NON-NLS-2$
+						+ ",args='" //$NON-NLS-1$
+						+ rsrvargs + "')\" " //$NON-NLS-1$
+				};	
+			}
+			// Mac, Linux
+			else {
+				cmdline = new String[] {
+						"/bin/sh", //$NON-NLS-1$
+						"-c", //$NON-NLS-1$
+						"echo 'library(Rserve);Rserve(" //$NON-NLS-1$
+						+ (debug ? "TRUE" : "FALSE") //$NON-NLS-1$ //$NON-NLS-2$
+						+ ",port="+port+"" //$NON-NLS-1$ //$NON-NLS-2$
+						+ ",args=\"" + rsrvargs //$NON-NLS-1$
+						+ "\")'|" + cmd //$NON-NLS-1$ 
+						+ " " + rargs }; //$NON-NLS-1$
+			}
+
+//			ProcessBuilder builder = new ProcessBuilder(cmdline);
+//			Rserveprocess = builder.start();
+
+			Runtime runtime = Runtime.getRuntime();
+			Rserveprocess = runtime.exec(cmdline);
+			
+			//Log.info(Messages.StartRserve_0+Arrays.toString(cmdline));
+			StreamHog errStream = new StreamHog(Rserveprocess.getErrorStream(), debug);
+			StreamHog inStream = new StreamHog(Rserveprocess.getInputStream(), debug);
+			RWorkspace.getRWorkspaceInstance().registerLogger(errStream, inStream);
+
+			if (!debug && !isWindows)
+				Rserveprocess.waitFor();
+			// System.out.println("call terminated, let us try to connect ...");
+		} catch (Exception x) {
+			System.err.println(Messages.StartRserve_21 + x.getMessage());
+			return false;
+		}
+
+		System.err.print(Messages.StartRserve_22);
+
+		try {
+			Thread.sleep(200);
+		} catch (InterruptedException ix) { }
+
+		int attempts = 20;
+		while (attempts > 0) {
+			try {
+				System.out.print("."); //$NON-NLS-1$
+				RConnection c = new RConnection("127.0.0.1", port); //$NON-NLS-1$
+				c.close();
+				return true;
+			} catch (Exception e2) {
+				try {
+					Thread.sleep(2000);
+				} catch (InterruptedException ix) { }
+			}
+
+			attempts--;
+		}
+		System.out.println(""); //$NON-NLS-1$
+		return false;
+	}
+
+	/**
+	 * checks whether Rserve is running and if that's not the case it attempts
+	 * to start it using the defaults for the platform where it is run on. This
+	 * method is meant to be set-and-forget and cover most default setups. For
+	 * special setups you may get more control over R with <
+	 * <code>launchRserve</code> instead.
+	 * @param rServeArgs 
+	 * @param rargs 
+	 *
+	 * @return true, if successful
+	 */
+	protected static boolean checkLocalRserve(int port, boolean debug, String rargs, String rServeArgs) {
+		Log.info(Messages.StartRserve_2);
+		if (isRserveRunning(port)) {
+			Log.info(Messages.StartRserve_3+port);
+			return true;
+		}
+		// Windows OS
+		if (OSDetector.isFamilyWindows()) {
+			// System.out.println("Windows: query registry to find where R is installed ...");
+			String installPath = null;
+			try {
+				Process rp = Runtime.getRuntime().exec(
+						"reg query HKLM\\Software\\R-core\\R"); //$NON-NLS-1$
+				StreamHog regHog = new StreamHog(rp.getInputStream(), true);
+				rp.waitFor();
+				regHog.join();
+				installPath = regHog.getInstallPath();
+			} catch (Exception rge) {
+				System.err.println(Messages.StartRserve_28 + rge);
+				return false;
+			}
+			if (installPath == null) {
+				System.err.println(Messages.StartRserve_29);
+				return false;
+			}
+			// System.out.println(" Found R in : "+installPath +
+			// "\\bin\\R.exe");
+			return launchRserve(installPath + "\\bin\\R.exe", port, debug, rargs, rServeArgs); //$NON-NLS-1$
+		}
+
+		Log.info(Messages.StartRserve_4);
+		if (launchRserve("R", port, debug, rargs, rServeArgs)) return true; //$NON-NLS-1$
+
+		// R not in the PATH env, try with R common paths
+		String[] paths = {
+				"/Library/Frameworks/R.framework/Resources/bin/R", //$NON-NLS-1$
+				"/usr/local/lib/R/bin/R", //$NON-NLS-1$
+				"/usr/lib/R/bin/R", //$NON-NLS-1$
+				"/sw/bin/R", //$NON-NLS-1$
+				"/usr/common/bin/R", //$NON-NLS-1$
+		"/opt/bin/R" }; //$NON-NLS-1$
+		for (String path : paths) {
+			Log.info(Messages.StartRserve_6+path);
+			if (new File(path).exists() && launchRserve(path, port, debug, rargs, rServeArgs)) return true;
+		}
+
+		return false;
+		//			
+		//		return (launchRserve("R", port, debug) //$NON-NLS-1$
+		//				|| /* try some common unix locations of R */
+		//				(( && launchRserve("/Library/Frameworks/R.framework/Resources/bin/R", port, debug)) //$NON-NLS-1$
+		//				|| ((new File("/usr/local/lib/R/bin/R")).exists() && launchRserve("/usr/local/lib/R/bin/R")) //$NON-NLS-1$ //$NON-NLS-2$
+		//				|| ((new File("/usr/lib/R/bin/R")).exists() && launchRserve("/usr/lib/R/bin/R")) //$NON-NLS-1$ //$NON-NLS-2$
+		//				|| ((new File("/usr/local/bin/R")).exists() && launchRserve("/usr/local/bin/R")) //$NON-NLS-1$ //$NON-NLS-2$
+		//				|| ((new File("/sw/bin/R")).exists() && launchRserve("/sw/bin/R")) //$NON-NLS-1$ //$NON-NLS-2$
+		//				|| ((new File("/usr/common/bin/R")).exists() && launchRserve("/usr/common/bin/R")) || ((new File( //$NON-NLS-1$ //$NON-NLS-2$
+		//				"/opt/bin/R")).exists() && launchRserve("/opt/bin/R"))); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	/**
+	 * check whether Rserve is currently running (on local machine and default
+	 * port).
+	 * 
+	 * @return <code>true</code> if local Rserve instance is running,
+	 *         <code>false</code> otherwise
+	 */
+	protected static boolean isRserveRunning(int port) {
+		try {
+			new RConnection("127.0.0.1", port); //$NON-NLS-1$
+			// System.out.println("Rserve is running.");
+			// c.close();
+			return true;
+		} catch (Exception e) {
+			// System.out.println("First connect try failed with: "+
+			// e.getMessage());
+		}
+		return false;
+	}
+
+
+	public static void main(String[] args) {
+		System.out.println("result=" + checkLocalRserve(8212, false, "", ""));
+		try {
+			System.out.println("Start RServe");
+			RConnection c = new RConnection("localhost", 8212);
+			System.out.println("Stop RServe");
+			c.eval("print(1+1)");
+			c.eval("2+2");
+			c.shutdown();
+			System.out.println("Done");
+		} catch (Exception x) {
+			x.printStackTrace();
+		}
+	}
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/StartRserve.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/RServeException.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/RServeException.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/RServeException.java	(revision 219)
@@ -0,0 +1,78 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class RServeException.
+ */
+public class RServeException extends RException {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Instantiates a new r serve exception.
+	 */
+	public RServeException() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new r serve exception.
+	 *
+	 * @param arg0 the arg0
+	 * @param arg1 the arg1
+	 */
+	public RServeException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new r serve exception.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RServeException(String arg0) {
+		super(arg0);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new r serve exception.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RServeException(Throwable arg0) {
+		super(arg0);
+		// TODO Auto-generated constructor stub
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/RServeException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/RFileCommunication.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/RFileCommunication.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/RFileCommunication.java	(revision 219)
@@ -0,0 +1,313 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2015-05-22 09:06:15 +0200 (Fri, 22 May 2015) $
+// $LastChangedRevision: 2973 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.Platform;
+import org.txm.utils.OSDetector;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class RFileCommunication.
+ */
+public class RFileCommunication {
+	
+	/** The transfertfile. */
+	File transfertfile;
+	
+	/** The transfertfilepath. */
+	String transfertfilepath;
+
+	/**
+	 * Instantiates a new r file communication.
+	 *
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public RFileCommunication() throws IOException
+	{
+		createTempFile();
+
+	}
+
+	/**
+	 * Creates the temp file.
+	 *
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public void createTempFile() throws IOException
+	{
+		transfertfile = File.createTempFile("Rtransfert","file"); //$NON-NLS-1$ //$NON-NLS-2$
+		//transfertfile = new File("~/Bureau/RTRANSFERT.txt");
+		transfertfilepath = transfertfile.getAbsolutePath();
+		if (OSDetector.isFamilyWindows()) //$NON-NLS-1$ //$NON-NLS-2$
+		{
+			//System.out.println("patch path");
+			transfertfilepath = transfertfilepath.replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
+		}
+		//System.out.println("Transfert file: "+transfertfilepath);
+	}
+
+	/**
+	 * Assign.
+	 *
+	 * @param variablename the variablename
+	 * @param matrix the matrix
+	 * @param nrow the nrow
+	 * @param ncol the ncol
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void assign(String variablename, int[] matrix, int nrow, int ncol) throws RWorkspaceException
+	{
+		writeVector(matrix);
+		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
+		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- matrix(vectorint, nrow="+nrow+", ncol="+ncol+", byrow=T);"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	}
+
+	/**
+	 * Assign.
+	 *
+	 * @param variablename the variablename
+	 * @param matrix the matrix
+	 * @param nrow the nrow
+	 * @param ncol the ncol
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void assign(String variablename, double[] matrix, int nrow, int ncol) throws RWorkspaceException
+	{
+		writeVector(matrix);
+		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
+		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- matrix(vectordouble, nrow="+nrow+", ncol="+ncol+", byrow=T);"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	}
+
+	/**
+	 * Assign.
+	 *
+	 * @param variablename the variablename
+	 * @param vector the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void assign(String variablename, int[] vector) throws RWorkspaceException
+	{
+		//System.out.println("assign vector "+variablename+" size "+vector.length);
+		writeVector(vector);
+		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
+		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- vectorint;"); //$NON-NLS-1$
+	}
+
+	/**
+	 * Assign.
+	 *
+	 * @param variablename the variablename
+	 * @param vector the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void assign(String variablename, double[] vector) throws RWorkspaceException
+	{
+		//System.out.println("assign vector "+variablename+" size "+vector.length);
+		writeVector(vector);
+		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
+		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- vectordouble;"); //$NON-NLS-1$
+		
+	}
+
+	/**
+	 * Assign.
+	 *
+	 * @param variablename the variablename
+	 * @param vector the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void assign(String variablename, String[] vector) throws RWorkspaceException
+	{
+		//System.out.println("assign vector "+variablename+" size "+vector.length);
+		writeVector(vector);
+		RWorkspace.getRWorkspaceInstance().eval("source(\""+transfertfilepath+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
+		RWorkspace.getRWorkspaceInstance().eval(variablename+" <- vectorstr;"); //$NON-NLS-1$
+	}
+
+	/*
+	public boolean writeMatrix(int[][] matrix)
+	{
+		//System.out.println("WRITE MATRIX");
+		try {
+			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
+			for(int i = 0 ; i < matrix.length ; i++)
+			{
+				StringBuffer str = new StringBuffer();
+				for(int j = 0 ; j < matrix[i].length ; j++)
+					if (j == matrix[i].length -1)
+						str.append(matrix[i][j]);
+					else
+						str.append(""+matrix[i][j]+"\t");
+				writer.write(str.toString()+"\n");
+			}
+			writer.close();
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+	public boolean writeMatrix(double[][] matrix)
+	{
+		//System.out.println("WRITE MATRIX");
+		try {
+			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
+			for(int i = 0 ; i < matrix.length ; i++)
+			{
+				StringBuffer str = new StringBuffer();
+				for(int j = 0 ; j < matrix[i].length ; j++)
+					if (j == matrix[i].length -1)
+						str.append(matrix[i][j]);
+					else
+						str.append(""+matrix[i][j]+"\t");
+				writer.write(str.toString()+"\n");
+			}
+			writer.close();
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+*/
+	/**
+	 * Write vector.
+	 *
+	 * @param vector the vector
+	 * @return true, if successful
+	 */
+	private boolean writeVector(String[] vector) {
+		//System.out.println("WRITE VECTOR");
+		try {
+			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
+
+			StringBuffer str = new StringBuffer();
+			str.append("vectorstr <- c("); //$NON-NLS-1$
+			for(int j = 0 ; j < vector.length ; j++)
+				if (j == vector.length -1)
+					str.append("\""+vector[j]+"\""); //$NON-NLS-1$ //$NON-NLS-2$
+				else
+					str.append("\""+vector[j]+"\", "); //$NON-NLS-1$ //$NON-NLS-2$
+			str.append(");"); //$NON-NLS-1$
+			writer.write(str.toString());
+
+			writer.close();
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Write vector.
+	 *
+	 * @param vector the vector
+	 * @return true, if successful
+	 */
+	public boolean writeVector(int[] vector)
+	{
+		//System.out.println("WRITE VECTOR");
+		try {
+			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
+
+			StringBuffer str = new StringBuffer();
+			str.append("vectorint <- as.integer(c("); //$NON-NLS-1$
+			for(int j = 0 ; j < vector.length ; j++)
+				if (j == vector.length -1)
+					str.append(vector[j]);
+				else
+					str.append(""+vector[j]+", "); //$NON-NLS-1$ //$NON-NLS-2$
+			str.append("));"); //$NON-NLS-1$
+			writer.write(str.toString());
+			writer.close();
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Write vector.
+	 *
+	 * @param vector the vector
+	 * @return true, if successful
+	 */
+	public boolean writeVector(double[] vector)
+	{
+		//System.out.println("WRITE VECTOR");
+		try {
+			BufferedWriter writer = new BufferedWriter(new FileWriter(transfertfilepath));
+
+			StringBuffer str = new StringBuffer();
+			str.append("vectordouble <- c("); //$NON-NLS-1$
+			for(int j = 0 ; j < vector.length ; j++)
+			{
+				if (j == vector.length -1)
+					str.append(vector[j]);
+				else
+					str.append(""+vector[j]+", "); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+			str.append(");"); //$NON-NLS-1$
+			writer.write(str.toString());
+			writer.close();
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args)
+	{
+		double[][] matrix ={{1,2,3}, {4,5,6}, {7,8,9}};
+		RFileCommunication comm;
+		try {
+			comm = new RFileCommunication();
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return;
+		}
+
+		//comm.writeMatrix(matrix);
+	}
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/RFileCommunication.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/Factor.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/Factor.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/Factor.java	(revision 219)
@@ -0,0 +1,61 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r.data;
+
+import org.txm.stat.engine.r.RWorkspaceException;
+import org.txm.Messages;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A wrapper on a R "factor".
+ * 
+ * @author sloiseau
+ * 
+ */
+public class Factor extends QuantitativeDataStructureImpl {
+
+	/**
+	 * Create a factor.
+	 *
+	 * @param values the values of the factor.
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public Factor(String values) throws RWorkspaceException {
+		throw new UnsupportedOperationException(Messages.Factor_0);
+	}
+
+	/**
+	 * The levels are the unordered set of dif ferent values present in the
+	 * factor.
+	 *
+	 * @return the levels
+	 */
+	public String[] getLevels() {
+		throw new UnsupportedOperationException(Messages.Factor_0);
+	}
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/Factor.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/package.html
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/package.html	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/package.html	(revision 219)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Implementation of quantitative data structures for representing corpus, as defined in package <code>org.txm.stat.data</code>, wrapping and hidding R data structures.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/DoubleMatrix.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/DoubleMatrix.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/DoubleMatrix.java	(revision 219)
@@ -0,0 +1,88 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r.data;
+
+import org.txm.stat.engine.r.RWorkspaceException;
+
+import cern.colt.matrix.DoubleMatrix2D;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A double matrix, backed to the R engine.
+ * 
+ * @author sloiseau
+ */
+public class DoubleMatrix extends MatrixImpl {
+
+	/**
+	 * Instantiates a new double matrix.
+	 *
+	 * @param matrix the matrix
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public DoubleMatrix(DoubleMatrix2D matrix) throws RWorkspaceException {
+		super(matrix);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new double matrix.
+	 *
+	 * @param mat the mat
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public DoubleMatrix(double[][] mat) throws RWorkspaceException {
+		super(mat);
+	}
+
+	/**
+	 * Instantiates a new double matrix.
+	 *
+	 * @param symbol the symbol
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public DoubleMatrix(String symbol) throws RWorkspaceException {
+		super(symbol);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new double matrix.
+	 *
+	 * @param matrix the matrix
+	 * @param rowNames the row names
+	 * @param columnNames the column names
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public DoubleMatrix(DoubleMatrix2D matrix, String[] rowNames,
+			String[] columnNames) throws RWorkspaceException {
+		super(matrix, rowNames, columnNames);
+		// TODO Auto-generated constructor stub
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/DoubleMatrix.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/RObjectDoesNotExist.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/RObjectDoesNotExist.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/RObjectDoesNotExist.java	(revision 219)
@@ -0,0 +1,79 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r.data;
+
+import org.txm.stat.engine.r.RWorkspaceException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Exception thrown if a symbol without corresponding object in the R workspace
+ * is used.
+ * 
+ * @author sloiseau
+ */
+public class RObjectDoesNotExist extends RWorkspaceException {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = -1344530765750521820L;
+
+	/**
+	 * Instantiates a new r object does not exist.
+	 */
+	public RObjectDoesNotExist() {
+		super();
+	}
+
+	/**
+	 * Instantiates a new r object does not exist.
+	 *
+	 * @param arg0 the arg0
+	 * @param arg1 the arg1
+	 */
+	public RObjectDoesNotExist(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+	/**
+	 * Instantiates a new r object does not exist.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RObjectDoesNotExist(String arg0) {
+		super(arg0);
+	}
+
+	/**
+	 * Instantiates a new r object does not exist.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RObjectDoesNotExist(Throwable arg0) {
+		super(arg0);
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/RObjectDoesNotExist.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/VectorImpl.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/VectorImpl.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/VectorImpl.java	(revision 219)
@@ -0,0 +1,363 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-08-29 14:23:55 +0200 (Thu, 29 Aug 2013) $
+// $LastChangedRevision: 2519 $
+// $LastChangedBy: nilskredens $ 
+//
+package org.txm.stat.engine.r.data;
+
+import java.util.List;
+
+import org.rosuda.REngine.REXP;
+import org.rosuda.REngine.REXPMismatchException;
+import org.txm.stat.StatException;
+import org.txm.stat.data.Vector;
+import org.txm.stat.engine.r.RWorkspaceException;
+import org.txm.stat.utils.ArrayIndex;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Implementation of the {@link Vector} interface, wrapping a R vector.
+ * 
+ * @author sloiseau
+ */
+public class VectorImpl extends QuantitativeDataStructureImpl implements Vector {
+
+	/**
+	 * This is final in order to be sure that a length is always defined, and
+	 * defined only once, on a vector.
+	 */
+	private int length;
+
+	/**
+	 * Instantiates a new vector.
+	 *
+	 * @param data the data
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public VectorImpl(int[] data) throws RWorkspaceException {
+		super();
+		rw.addVectorToWorkspace(symbol, data);
+		length = data.length;
+	}
+
+	/**
+	 * Instantiates a new vector impl.
+	 *
+	 * @param data the data
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public VectorImpl(double[] data) throws RWorkspaceException {
+		super();
+		rw.addVectorToWorkspace(symbol, data);
+		length = data.length;
+	}
+
+	/**
+	 * Instantiates a new vector impl.
+	 *
+	 * @param data the data
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public VectorImpl(String[] data) throws RWorkspaceException {
+		super();
+		rw.addVectorToWorkspace(symbol, data);
+		length = data.length;
+	}
+	
+	/**
+	 * Instantiates a new vector.
+	 *
+	 * @param data the data
+	 * @param symbol the symbol
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public VectorImpl(int[] data, String symbol) throws RWorkspaceException {
+		super();
+		this.symbol = symbol;
+		rw.addVectorToWorkspace(symbol, data);
+		length = data.length;
+	}
+
+	/**
+	 * Instantiates a new vector impl.
+	 *
+	 * @param data the data
+	 * @param symbol the symbol
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public VectorImpl(double[] data, String symbol) throws RWorkspaceException {
+		super();
+		this.symbol = symbol;
+		rw.addVectorToWorkspace(symbol, data);
+		length = data.length;
+	}
+
+	/**
+	 * Instantiates a new vector impl.
+	 *
+	 * @param data the data
+	 * @param symbol the symbol
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public VectorImpl(String[] data, String symbol) throws RWorkspaceException {
+		super();
+		this.symbol = symbol;
+		rw.addVectorToWorkspace(symbol, data);
+		length = data.length;
+	}
+
+	/**
+	 * Constructing a Vector when the R object already exists in the workspace:
+	 * we only want to record its symbol in a java object.
+	 *
+	 * @param symbol the symbol
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public VectorImpl(String symbol) throws RWorkspaceException {
+		super(symbol);
+		try {
+			length = rw.eval("length(" + symbol + ")").asInteger(); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+	}
+
+	/**
+	 * Sets the r names.
+	 *
+	 * @param vals the new r names
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void setRNames(String[] vals) throws RWorkspaceException {
+		Vector names = new VectorImpl(vals);
+
+		StringBuffer exp = new StringBuffer();
+		exp.append("names("); //$NON-NLS-1$
+		exp.append(symbol);
+		exp.append(")"); //$NON-NLS-1$
+		exp.append("<-"); //$NON-NLS-1$
+		exp.append(names.getSymbol());
+		exp.append(";"); //$NON-NLS-1$
+
+		rw.voidEval(exp.toString());
+		rw.voidEval("rm(" + names.getSymbol() + ");"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	/**
+	 * Gets the r names.
+	 * 
+	 * @param string
+	 *            the string
+	 * 
+	 * @return the r names
+	 * 
+	 * @throws RWorkspaceException
+	 *             the r workspace exception
+	 */
+	public void getRNames(String[] string) throws RWorkspaceException {
+		getAttribute("names"); //$NON-NLS-1$
+	}
+
+	/**
+	 * Get a new vector with a copy of the value at the specif ied index in this
+	 * vector.
+	 *
+	 * @param index the index
+	 * @return the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	@Override
+	public Vector get(int[] index) throws RWorkspaceException {
+		int[] rIndex = ArrayIndex.zeroToOneBasedIndex(index, this.length);
+		// TODO Auto-generated method stub
+		String name_index = createSymbole(Vector.class);
+		rw.addVectorToWorkspace(name_index, rIndex);
+		String name = createSymbole(Vector.class);
+		rw.voidEval(name + "<- " + symbol + "[ " + name_index + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		return new VectorImpl(name);
+	}
+
+	/**
+	 * Throw a {@link RWorkspaceException} if the vector is not of type integer.
+	 *
+	 * @return the int[]
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	@Override
+	public int[] asIntArray() throws RWorkspaceException {
+		try {
+			return rw.eval(symbol).asIntegers();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#asStringsArray()
+	 */
+	@Override
+	public String[] asStringsArray() throws StatException {
+		try {
+			return rw.eval(symbol).asStrings();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#asDoubleArray()
+	 */
+	@Override
+	public double[] asDoubleArray() throws StatException {
+		try {
+			return rw.eval(symbol).asDoubles();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#getLength()
+	 */
+	@Override
+	public int getLength() throws StatException {
+		return length;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#remove(int)
+	 */
+	@Override
+	public boolean remove(int index) {
+		try {
+			if (index < this.length) {
+				rw.eval(symbol + " <- " + symbol + "[-" + (index + 1) + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				length--;
+			}
+		} catch (RWorkspaceException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#setString(int, java.lang.String)
+	 */
+	@Override
+	public void setString(int index, String value) {
+		try {
+			if (index < this.length) {
+				rw.eval(symbol + "[" + (index + 1) + "] <-\"" + value + "\";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			}
+		} catch (RWorkspaceException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#setDouble(int, double)
+	 */
+	@Override
+	public void setDouble(int index, double value) {
+		try {
+			if (index < this.length) {
+				rw.eval(symbol + "[" + (index + 1) + "] <-" + value + ";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			}
+		} catch (RWorkspaceException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#setInt(int, int)
+	 */
+	@Override
+	public void setInt(int index, int value) {
+		try {
+			if (index < this.length) {
+				rw.eval(symbol + "[" + (index + 1) + "] <-" + value + ";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			}
+		} catch (RWorkspaceException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#sort(java.lang.Boolean)
+	 */
+	@Override
+	public void sort(Boolean reverse) {
+		try {
+			//System.out.println("R sort rownames Reverse" + reverse);
+			REXP r = rw
+					.eval(symbol
+							+ "<- " + symbol + "[order(" + symbol + ", decreasing = " + reverse.toString().toUpperCase() + ")];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#setOrder(java.util.List, java.lang.Boolean)
+	 */
+	@Override
+	public void setOrder(List<Integer> neworder, Boolean reverse) {
+		if (neworder.size() != this.length)
+			return;
+		String order = "c("; //$NON-NLS-1$
+		if (reverse) {
+			for (int i = neworder.size() - 1; i >= 0; i--)
+				order += "" + (neworder.get(i) + 1) + ", "; //$NON-NLS-1$ //$NON-NLS-2$
+		} else {
+			for (Integer i : neworder)
+				order += "" + (i + 1) + ", "; //$NON-NLS-1$ //$NON-NLS-2$
+		}
+		order = order.substring(0, order.length() - 2);
+		order += ")"; //$NON-NLS-1$
+		try {
+			// System.out.println("R sort rownames Reverse"+reverse);
+			REXP r = rw.eval(symbol + "<- " + symbol + "[" + order + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Vector#cut(int)
+	 */
+	@Override
+	public void cut(int nlines) {
+		try {
+			// cut nlines
+			REXP r = rw.eval(symbol + "<- " + symbol + "[1:" + (nlines) + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/VectorImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/MatrixImpl.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/MatrixImpl.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/MatrixImpl.java	(revision 219)
@@ -0,0 +1,1048 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2015-05-22 09:06:15 +0200 (Fri, 22 May 2015) $
+// $LastChangedRevision: 2973 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r.data;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Platform;
+import org.rosuda.REngine.REXP;
+import org.rosuda.REngine.REXPMismatchException;
+import org.txm.stat.StatException;
+import org.txm.stat.data.Matrix;
+import org.txm.stat.data.Vector;
+import org.txm.stat.engine.r.RException;
+import org.txm.stat.engine.r.RWorkspace;
+import org.txm.stat.engine.r.RWorkspaceException;
+import org.txm.stat.utils.ArrayIndex;
+import org.txm.utils.CharsetDetector;
+import org.txm.utils.OSDetector;
+
+import cern.colt.matrix.DoubleMatrix2D;
+
+import org.txm.Messages;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Implementation of the {@link Matrix} interface, wrapping a R matrix.
+ * 
+ * define the methods to edit/delete elements in the matrix
+ * 
+ * @author sloiseau
+ */
+public class MatrixImpl extends QuantitativeDataStructureImpl
+implements Matrix {
+
+
+	public static int[][] asIntMatrix(REXP r) throws REXPMismatchException {
+
+		int[] ct = r.asIntegers();
+		if (ct == null) return null;
+		REXP dim = r.getAttribute("dim"); //$NON-NLS-1$
+		int[] ds = dim.asIntegers();
+		if (ds == null || ds.length != 2)
+			return null; // matrix must be 2-dimensional
+
+		int m = ds[0], n = ds[1];
+		int[][] rez = new int[m][n];
+
+		// R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4)
+		// we need to copy everything, since we create 2d array from 1d array
+		int i = 0, k = 0;
+		while (i < n) {
+			int j = 0;
+			while (j < m) {
+				rez[j++][i] = ct[k++];
+			}
+			i++;
+		}
+		return rez;
+	}
+
+	//	/** The ncol. */
+	//	protected int ncol;
+	//	
+	//	/** The nrow. */
+	//	protected int nrow;
+
+
+	/**
+	 * Instantiates a new matrix impl.
+	 *
+	 * @param matrix the matrix
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public MatrixImpl(double[][] matrix) throws RWorkspaceException {
+		super();
+		rw.addMatrixToWorkspace(symbol, matrix);
+		//		this.nrow = matrix.length;
+		//		this.ncol = matrix[0].length;
+		//this.rows = null;
+		//this.cols = null;
+	}
+
+	/**
+	 * Instantiates a new matrix impl.
+	 *
+	 * @param matrix the matrix
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public MatrixImpl(DoubleMatrix2D matrix) throws RWorkspaceException {
+		super();
+		rw.addMatrixToWorkspace(symbol, matrix);
+		//		this.nrow = matrix.rows();
+		//		this.ncol = matrix.columns();
+		//this.rows = null;
+		//this.cols = null;
+	}
+
+	/**
+	 * Create a new matrix given a {@link DoubleMatrix2D}, with row and col
+	 * names.
+	 *
+	 * @param matrix the matrix
+	 * @param rowNames row names.
+	 * @param columnNames the column names
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public MatrixImpl(DoubleMatrix2D matrix, String[] rowNames,
+			String[] columnNames) throws RWorkspaceException {
+		this(matrix);
+
+		if (rowNames == null) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_4);
+		}
+		//		if (rowNames.length != nrow) {
+		//			throw new IllegalArgumentException(Messages.MatrixImpl_5);
+		//		}
+		//this.rows = new VectorImpl(rowNames);
+		rw.assignRowNamesToMatrix(symbol, new VectorImpl(rowNames).getSymbol());
+
+		if (columnNames == null) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_6);
+		}
+		//		if (columnNames.length != ncol) {
+		//			throw new IllegalArgumentException(Messages.MatrixImpl_7
+		//					+ columnNames.length + ", " + ncol + ")."); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+		//		}
+		//this.cols = new VectorImpl(columnNames);
+		rw.assignColNamesToMatrix(symbol, new VectorImpl(columnNames).getSymbol());
+
+	}
+
+	/**
+	 * Instantiates a new matrix impl.
+	 *
+	 * @param matrix the matrix
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public MatrixImpl(int[][] matrix) throws RWorkspaceException {
+		super();
+		rw.addMatrixToWorkspace(symbol, matrix);
+		//		this.nrow = matrix.length;
+		//		if (matrix.length > 0)
+		//			this.ncol = matrix[0].length;
+		//		else
+		//			this.ncol = 0;
+		//this.rows = null;
+		//this.cols = null;
+	}
+	
+	public void exchangeColumns(int c1, int c2) {
+		try {
+			RWorkspace rw = RWorkspace.getRWorkspaceInstance();
+			rw.eval("tmp <- "+symbol+"[,"+c1+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			rw.eval(symbol+"[,"+c1+"] <- "+symbol+"[,"+c2+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			rw.eval(symbol+"[,"+c2+"] <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$
+			rw.eval("tmp <- colnames("+symbol+")["+c1+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			rw.eval("colnames("+symbol+")["+c1+"] <- colnames("+symbol+")["+c2+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+			rw.eval("colnames("+symbol+")["+c2+"] <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Instantiates a new matrix impl.
+	 *
+	 * @param matrix the matrix
+	 * @param lineNames the form names
+	 * @param partNames the part names
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public MatrixImpl(int[][] matrix, String[] lineNames, String[] partNames) throws RWorkspaceException {
+		this(matrix);
+
+		if (lineNames == null) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_4);
+		}
+		//		if (lineNames.length != nrow) {
+		//			throw new IllegalArgumentException(Messages.MatrixImpl_5);
+		//		}
+		//this.rows = ;
+		rw.assignRowNamesToMatrix(symbol, new VectorImpl(lineNames).getSymbol());
+
+		if (partNames == null) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_6);
+		}
+		//		if (partNames.length != ncol) {
+		//			throw new IllegalArgumentException(Messages.MatrixImpl_7
+		//					+ partNames.length + ", " + ncol + ")."); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+		//		}
+		//this.cols = new VectorImpl(partNames);
+		rw.assignColNamesToMatrix(symbol, new VectorImpl(partNames).getSymbol());
+
+	}
+
+	/**
+	 * Create a matrix wrapping data already existing into R with the given
+	 * symbol.
+	 * 
+	 * This method is protected on purpose : only classes in this package,
+	 * dealing with the R workspace, may have direct access to R objects.
+	 *
+	 * @param symbol the name of R object existing in the workspace.
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	protected MatrixImpl(String symbol) throws RWorkspaceException {
+		super(symbol);
+		if (!rw.containsVariable(symbol)) {
+			throw new RObjectDoesNotExist(Messages.MatrixImpl_0 + symbol
+					+ Messages.MatrixImpl_1);
+		}
+		REXP res = rw.eval("dim(" + symbol + ")"); //$NON-NLS-2$ //$NON-NLS-1$
+		int[] dim = null;
+		try {
+			dim = res.asIntegers();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+		//		nrow = dim[0];
+		//		ncol = dim[1];
+		//this.rows = null;
+		//this.cols = null;
+	}
+
+	/**
+	 * Removes the row with a negative index.
+	 * @param row the row [1..N]
+	 */
+	public void _removeRow(int row) {
+		// dans R theMatrixWithoutRow5 = theMatrix[-5,]
+		try {
+			REXP r = rw.eval(symbol
+					+ " <- " + symbol + "[ " + row + ",];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			//nrow--;
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		// de la liste rows
+	}
+
+	/**
+	 * Cut.
+	 *
+	 * @param nRowToCut the nlines
+	 * @throws StatException 
+	 */
+	public void cut(int nRowToCut){
+		if (nRowToCut > this.getNRows())
+			return;
+
+		try {
+			// cut nlines
+			REXP r = rw.eval(symbol
+					+ "<- " + symbol + "[1:" + (nRowToCut) + ", ];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			getRowNames().cut(nRowToCut);
+			//this.nrow = nlines;
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	// public String[] rownames() throws RWorkspaceException {
+	// return rw.evalToString("rownames(" + symbol + ");");
+	// }
+
+	/**
+	 * Export data.
+	 *
+	 * @param f the f
+	 * @param colseparator the colseparator
+	 * @param txtseparator the txtseparator
+	 */
+	public void exportData(File f, String colseparator, String txtseparator) {
+		try {
+			org.txm.stat.engine.r.RWorkspace
+			.getRWorkspaceInstance().safeEval(
+					"write.table(" + symbol + ", file=\"" + f.getAbsolutePath().replace("\\", "\\\\") + "\", fileEncoding=\"UTF-8\");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ 
+		} catch (Exception e1) {
+			org.txm.utils.logger.Log.printStackTrace(e1);
+			RWorkspace.printLastSafeEvalExpr();
+		}
+	}
+
+	/**
+	 * Filter.
+	 *
+	 * @param freqs the freqs
+	 * @param nlines the nlines
+	 * @param fmin the fmin
+	 * @throws REXPMismatchException 
+	 * @throws RWorkspaceException 
+	 * @throws StatException 
+	 */
+	public void filter(int nlines, int fmin) throws RWorkspaceException, REXPMismatchException {
+		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
+
+		// first sort rows
+		rw.eval("freqs <- rowSums("+symbol+")"); //$NON-NLS-1$ //$NON-NLS-2$
+		int[] freqs = rw.eval("freqs").asIntegers(); //$NON-NLS-1$
+		rw.eval("order <- sort(freqs, decreasing= TRUE, index.return= TRUE)"); //$NON-NLS-1$
+		//rw.eval("print(order)");
+		int[] order = rw.eval("order$ix").asIntegers();  //$NON-NLS-1$
+		rw.eval(symbol + "<- " + symbol + "[order$ix, ];"); //$NON-NLS-1$ //$NON-NLS-2$
+
+		// find first fmin line
+		int ifmin = 999999999;
+		for (int i = 0 ; i < order.length ; i++) {
+			//System.out.print("\t"+i+" freqs["+order[i]+"]"+freqs[order[i]-1]);
+			if (freqs[order[i]-1] < fmin) { // minus 1 because of R indexes
+				ifmin = i; // the ith line
+				break;
+			}
+		}
+		//System.out.println("iFmin: "+ifmin);
+
+		//cut
+		cut(Math.min(nlines, ifmin));
+	}
+
+	public void sortByFreqs(boolean reverse) throws RWorkspaceException, REXPMismatchException {
+		rw.eval("freqs <- rowSums("+symbol+")"); //$NON-NLS-1$ //$NON-NLS-2$
+		String DECREASING = "FALSE"; //$NON-NLS-1$
+		if (reverse) DECREASING = "TRUE"; //$NON-NLS-1$
+		rw.eval("order <- sort(freqs, decreasing= "+DECREASING+", index.return= TRUE)"); //$NON-NLS-1$ //$NON-NLS-2$
+		rw.eval(symbol + "<- " + symbol + "[order$ix, ];"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	/**
+	 * Fusion rows.
+	 *
+	 * @param row the row
+	 * @throws RWorkspaceException 
+	 */
+	public boolean mergeRows(int[] rows) throws RWorkspaceException {
+		if (rows.length < 2) return false;
+		Arrays.sort(rows);
+		//System.out.println("fusion rows: "+Arrays.toString(rows)); //$NON-NLS-1$
+		int rowToChange = rows[0] + 1;
+		rw.addVectorToWorkspace("rowsToMerge", ArrayIndex.zeroToOneBasedIndex(rows, rows.length)); //$NON-NLS-1$
+		RWorkspace.getRWorkspaceInstance().eval("newrow <- colSums("+symbol+"[rowsToMerge,])"); //$NON-NLS-1$ //$NON-NLS-2$
+		RWorkspace.getRWorkspaceInstance().eval(symbol+"["+rowToChange+",] <- newrow"); //$NON-NLS-1$ //$NON-NLS-2$
+
+		this.removeRows(Arrays.copyOfRange(rows, 1, rows.length)); // remove rows minus the first row to remove
+
+		return true;
+	}
+
+	/**
+	 * Fusion rows.
+	 *
+	 * @param row the row
+	 * @throws RWorkspaceException 
+	 */
+	public boolean mergeCols(int[] cols) throws RWorkspaceException {
+		if (cols.length < 2) return false;
+		Arrays.sort(cols);
+		//System.out.println("fusion rows: "+Arrays.toString(rows)); //$NON-NLS-1$
+		int colToChange = cols[0] + 1;
+		rw.addVectorToWorkspace("colsToMerge", ArrayIndex.zeroToOneBasedIndex(cols, cols.length)); //$NON-NLS-1$
+		RWorkspace.getRWorkspaceInstance().eval("newcol <- rowSums("+symbol+"[,colsToMerge])"); //$NON-NLS-1$ //$NON-NLS-2$
+		RWorkspace.getRWorkspaceInstance().eval(symbol+"[,"+colToChange+"] <- newcol"); //$NON-NLS-1$ //$NON-NLS-2$
+
+		this.removeCols(Arrays.copyOfRange(cols, 1, cols.length)); // remove rows minus the first row to remove
+
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#get(int, int)
+	 */
+	@Override
+	public double get(int row, int col) throws RException, RWorkspaceException {
+		int ncol = this.getNColumns();
+		int	nrow = this.getNRows();
+
+		if (row < 0 || row >= nrow) {
+			//throw new IllegalArgumentException(Messages.MatrixImpl_10 + row + Messages.MatrixImpl_11 + nrow + ")"); //$NON-NLS-3$ //$NON-NLS-1$ //$NON-NLS-1$
+		}
+		if (col < 0 || col >= ncol) {
+			//throw new IllegalArgumentException(Messages.MatrixImpl_13 + col + Messages.MatrixImpl_14 + ncol + ")"); //$NON-NLS-3$ //$NON-NLS-1$ //$NON-NLS-1$
+		}
+		REXP r = rw.eval(symbol
+				+ "[" + ArrayIndex.zeroToOneBasedIndex(row) + ", " + ArrayIndex.zeroToOneBasedIndex(col) + " ];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		if (r.isInteger()) {
+			try {
+				return r.asInteger();
+			} catch (REXPMismatchException e) {
+				throw new RWorkspaceException(e);
+			}
+		} else if (r.isComplex()) {
+			try {
+				return r.asDouble();
+			} catch (REXPMismatchException e) {
+				throw new RWorkspaceException(e);
+			}
+		} else if (r.isNumeric()) {
+			try {
+				return r.asDouble();
+			} catch (REXPMismatchException e) {
+				throw new RWorkspaceException(e);
+			}
+		} else if (r.isNull()) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_19);
+		} else {
+			// System.out.println("row: " + row);
+			// System.out.println("col: " + col);
+			// System.out.println("nrow: " + nrow);
+			// System.out.println("ncol: " + ncol);
+			// System.out.println(rw.eval("print(" + getSymbol() + ");"));
+			throw new IllegalArgumentException(Messages.MatrixImpl_20
+					+ r.getAttribute(Messages.MatrixImpl_21));
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#getCol(int)
+	 */
+	@Override
+	public Vector getCol(int index) throws RException, RWorkspaceException {
+		int ncol = this.getNColumns();
+
+		if (index < 0 || index >= ncol) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_28 + index
+					+ Messages.MatrixImpl_29 + ncol + ")"); //$NON-NLS-1$ 
+		}
+		String colName = createSymbole(Vector.class);
+		rw.voidEval(colName + "<- " + symbol + "[ ," + (index + 1) + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		return new VectorImpl(colName);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#getCol(java.lang.String)
+	 */
+	@Override
+	public Vector getCol(String column) throws RWorkspaceException {
+		String colName = createSymbole(Vector.class);
+		rw.voidEval(colName + "<- " + symbol + "[ ,\"" + column + "\"];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		return new VectorImpl(colName);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#getColNames()
+	 */
+	@Override
+	public Vector getColNames() {
+		try {
+			return new VectorImpl("colnames("+this.getSymbol()+")"); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return null;
+		}
+	}
+
+	public int[][] getIntData() {
+		try {
+			REXP rexp = RWorkspace.getRWorkspaceInstance().eval(this.symbol);
+			return asIntMatrix(rexp);
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (REXPMismatchException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#getNColumns()
+	 */
+	@Override
+	public int getNColumns() {
+		try {
+			return RWorkspace.getRWorkspaceInstance().eval(Messages.MatrixImpl_2+symbol+")[2]").asInteger(); //$NON-NLS-2$
+		} catch (Exception e) {
+			System.out.println("Matrix: failed to get nrow: "+e); //$NON-NLS-1$
+		}
+		return 0;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#getNRows()
+	 */
+	@Override
+	public int getNRows() {
+		try {
+			return RWorkspace.getRWorkspaceInstance().eval(Messages.MatrixImpl_2+symbol+")[1]").asInteger(); //$NON-NLS-2$
+		} catch (Exception e) {
+			System.out.println(Messages.MatrixImpl_67+e);
+		}
+		return 0;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#getRow(int)
+	 */
+	@Override
+	public Vector getRow(int index) throws RException, RWorkspaceException {
+		int nrow = getNRows();
+		if (index < 0 || index >= nrow) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_22 + index
+					+ Messages.MatrixImpl_23 + nrow + ")"); //$NON-NLS-1$ 
+		}
+		String rowName = createSymbole(Vector.class);
+		rw.voidEval(rowName + "<- " + symbol + "[" + (index + 1) + ", ];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		return new VectorImpl(rowName);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#getRow(java.lang.String)
+	 */
+	@Override
+	public Vector getRow(String row) throws RWorkspaceException {
+		String rowName = createSymbole(Vector.class);
+		rw.voidEval(rowName + "<- " + symbol + "[ \"" + row + "\" , ];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		return new VectorImpl(rowName);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.Matrix#getRowNames()
+	 */
+	@Override
+	public Vector getRowNames() {
+		try {
+			return new VectorImpl("rownames("+this.getSymbol()+")"); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return null;
+		}
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.ContingencyTable#getRowMargin()
+	 */
+	public int[] getRowMargins() throws StatException {
+		try {
+			return rw.eval("rowSums(" + this.symbol + ");").asIntegers(); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (REXPMismatchException e) {
+			throw new StatException(e);
+		} 
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.ContingencyTable#getRowMargin()
+	 */
+	public int[] getColMargins() throws StatException {
+		try {
+			return rw.eval("colSums(" + this.symbol + ");").asIntegers(); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (Exception e) {
+			throw new StatException(e);
+		}
+	}
+
+	/**
+	 * Import data.
+	 *
+	 * @param f the f
+	 * @throws RWorkspaceException 
+	 * @throws REXPMismatchException 
+	 */
+	public boolean importData(File f) throws RWorkspaceException, REXPMismatchException {
+
+		String path = f.getAbsolutePath();
+		
+		CharsetDetector guesser = new CharsetDetector(f);
+		if (!("UTF-8".equals(guesser.getEncoding().toUpperCase()))) {
+			System.out.println("Warning: file encoding seems to not be 'UTF-8' but '"+guesser.getEncoding()+"'");
+		}
+		
+		int nline = 0;
+		try {
+			BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
+			while(reader.readLine() != null) nline++;
+			reader.close();
+		} catch(Exception e) { }
+		
+		if (nline == 0) {
+			System.out.println("Error: the file is empty");
+			return false;
+		}
+		
+		if (OSDetector.isFamilyWindows()) //$NON-NLS-1$ //$NON-NLS-2$
+			path = path.replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
+		rw.voidEval("tmpmat <- as.matrix(read.table(file=\"" + path + "\", fileEncoding=\"UTF-8\"));"); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		rw.voidEval("a <- colnames(tmpmat)"); //$NON-NLS-1$
+		rw.voidEval("if (length(grep(\"X.+\", a)) == length(a)) {"+ //$NON-NLS-1$
+				" strcut <- function(x) substr(x, 2, nchar(x)) ;"+ //$NON-NLS-1$
+				" for(i in 1:length(a)) { a[i] <- strcut(a[i]) } ; "+ //$NON-NLS-1$
+				" colnames(tmpmat) <- a; }"); //$NON-NLS-1$
+		
+		// check number of columns
+		int colsize = rw.eval("dim(tmpmat)[2]").asInteger(); //$NON-NLS-1$
+		int linesize = rw.eval("dim(tmpmat)[1]").asInteger(); //$NON-NLS-1$
+		int ncol = this.getNColumns();
+		if (colsize != ncol) {
+			System.out.println(Messages.MatrixImpl_73+ncol+" imported="+colsize); //$NON-NLS-2$
+			return false;
+		}
+		
+		rw.eval(symbol +"<- tmpmat"); //$NON-NLS-1$
+		
+		nline--;
+		if (nline != linesize) {
+			System.out.println("Warning: some lines have not been read. Check your file format (header, encoding=UTF-8, separator=TAB)");
+			System.out.println("Number of lines in the file="+nline);
+			System.out.println("Number of lines in the matrix="+linesize);
+		}
+		return true;
+	}
+
+	public void print() {
+
+		try {
+			String[] rowNames = this.getRowNames().asStringsArray();
+			String[] colNames = this.getColNames().asStringsArray();
+			int[][] data = getIntData();
+
+			// col names
+			for (String col : colNames)
+				System.out.print("\t"+col); //$NON-NLS-1$
+					System.out.println();		
+					for (int i = 0 ; i < rowNames.length ; i++) {
+						System.out.print(rowNames[i]);
+						for (int j = 0 ; j < colNames.length ; j++) {
+							System.out.print("\t"+data[i][j]); //$NON-NLS-1$
+						}
+						System.out.println();
+					}
+		} catch (StatException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Removes the col.
+	 *
+	 * @param col the col
+	 * @param checkEmptyLines the check empty lines
+	 */
+	public void removeCol(int col) {
+		//System.out.println("rmv col " + col);
+		try {
+			REXP r = rw.eval(symbol + " <- " + symbol + "[,-" + ArrayIndex.zeroToOneBasedIndex(col) + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Removes the col and delete empty rows.
+	 *
+	 * @param col the col
+	 * @param checkEmptyLines the check empty lines
+	 */
+	public void removeCol(int col, boolean checkEmptyLines) {
+		//System.out.println("rmv col " + col);
+		try {
+			removeCol(col);
+
+			//we remove the empty lineslines
+			if (checkEmptyLines) {
+				removeEmptyRows();
+			}
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Removes the cols.
+	 *
+	 * @param cols the cols
+	 */
+	public void removeCols(int[] cols) {
+		Arrays.sort(cols);
+		int index = 0;
+		for (int i = cols.length - 1; i >= 0; i--) {
+			index = cols[i];
+			removeCol(index, false);
+		}
+	}
+
+	public void removeCols(int[] cols, boolean removeEmptyLines) throws RWorkspaceException {
+		removeCols(cols);
+		if (removeEmptyLines) removeEmptyRows();
+	}
+
+	/**
+	 * Removes the cols.
+	 *
+	 * @param cols the cols
+	 */
+	public void removeCols(List<Integer> cols) {
+		Collections.sort(cols);
+		int index = 0;
+		for (int i = cols.size() - 1; i >= 0; i--) {
+			index = cols.get(i);
+			removeCol(index, false);
+		}
+	}
+
+	public void removeCols(List<Integer> cols, boolean removeEmptyLines) throws RWorkspaceException {
+		removeCols(cols);
+		if (removeEmptyLines) {
+			removeEmptyRows();
+		}
+	}
+
+	private void removeEmptyCols() throws RWorkspaceException {
+		try {
+			int[] colsums = rw.eval("apply("+symbol+",2,sum)").asIntegers();//get a vector of line sums //$NON-NLS-1$ //$NON-NLS-2$
+			ArrayList<Integer> removecols = new ArrayList<Integer>();
+			// get the empty line index
+			for (int i = 0 ; i < colsums.length ; i++) {
+				if (colsums[i] == 0)
+					removecols.add(i);
+			}
+
+			if (removecols.size() > 0) {
+				removeCols(removecols);
+			}
+		} catch (REXPMismatchException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Removes the empty lines.
+	 *
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void removeEmptyRows() throws RWorkspaceException
+	{
+		try {
+			int[] rowsums = rw.eval("apply("+symbol+",1,sum)").asIntegers();//get a vector of line sums //$NON-NLS-1$ //$NON-NLS-2$
+			ArrayList<Integer> rowIndexes = new ArrayList<Integer>();
+			// get the empty line index
+			for (int i = 0 ; i < rowsums.length ; i++) {
+				if (rowsums[i] == 0)
+					rowIndexes.add(i);
+			}
+
+			if (rowIndexes.size() > 0) {
+				removeRows(rowIndexes);
+			}
+		} catch (REXPMismatchException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Removes the row.
+	 *
+	 * @param row the row
+	 */
+	public void removeRow(int row) {
+		// dans R theMatrixWithoutRow5 = theMatrix[-5,]
+		try {
+			REXP r = rw.eval(symbol
+					+ " <- " + symbol + "[ -" + ArrayIndex.zeroToOneBasedIndex(row) + ",];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		// de la liste rows
+	}
+
+	/**
+	 * Removes the rows.
+	 *
+	 * @param from the from
+	 * @param to the to
+	 */
+	public void removeRows(int from, int to) {
+		int nrow = this.getNRows();
+		if (0 <= from && from <= to && to < nrow) {
+			for (int i = to; i >= from; i--) {
+				removeRow(i);
+			}
+		}
+	}
+
+	/**
+	 * Removes the rows indexes.
+	 *
+	 * @param rows the rows
+	 */
+	public void removeRows(int[] rows) {
+		if (rows.length == 0) return;
+		int nrow = this.getNRows();
+		try {
+			Arrays.sort(rows);
+			for (int i = 0 ; i < rows.length ; i++) {
+				rows[i] = - (rows[i]+1);
+			}
+			int idx = rows[0];
+			if (rows.length > 1) {
+				int[] subrows = new int[rows.length-1];
+				System.arraycopy(rows, 1, subrows, 0, rows.length - 1);
+				rw.addVectorToWorkspace("linesToDelete", subrows); //$NON-NLS-1$
+				//System.out.println("all lines to delete: "+Arrays.toString(rows));
+				//System.out.println("lines to delete: "+Arrays.toString(subrows));
+				REXP r = rw.eval(symbol + " <- " + symbol + "[ linesToDelete,];"); //$NON-NLS-1$ //$NON-NLS-2$
+				nrow -= rows.length - 1;
+			}
+
+			if (nrow == 2) {
+				// 2 lines left
+				int last = 1;
+				if (idx == -1) last = 2;
+				String[] rowNames;
+				try {
+					rowNames = getRowNames().asStringsArray();
+				} catch (StatException e) {
+					System.out.println(Messages.MatrixImpl_79);
+					org.txm.utils.logger.Log.printStackTrace(e);
+					return;
+				}
+				String lastRowName = rowNames[last-1];
+				REXP r = rw.eval(this.symbol+"<-matrix("+this.symbol+"["+idx+",], nrow=1, dimnames = list(rownames=\""+lastRowName+"\", colnames("+this.symbol+")))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+				//_removeRow(idx);
+				nrow = 1;
+			} else {
+				//System.out.println("remove last row: "+idx);
+				_removeRow(idx);
+			}
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	public void removeRows(int[] rows, boolean removeEmptyCols) throws RWorkspaceException {
+		removeRows(rows);
+		if (removeEmptyCols) removeEmptyCols();
+	}
+
+	/**
+	 * Removes the rows.
+	 *
+	 * @param rows the row
+	 */
+	public void removeRows(List<Integer> rows) {
+
+		Collections.sort(rows);
+		//System.out.println("del rows " + row);
+		int index = 0;
+		int nrow = this.getNRows();
+		int diff = Math.abs(rows.size() - nrow);
+		if (diff > 1) {
+			for (int i = rows.size() - 1; i >= 0; i--) {
+				index = rows.get(i);
+				removeRow(index);
+			}
+		} else if (diff == 1) {
+			for (int i = rows.size() - 2; i >= 0; i--) {
+				index = rows.get(i);
+				removeRow(index);
+			}
+			// 2 lines left
+			int idx = rows.get(rows.size() - 1);
+			int last = 0;
+			if (idx == 0)
+				last = 1;
+			String[] rowNames;
+			try {
+				rowNames = getRowNames().asStringsArray();
+			} catch (StatException e) {
+				System.out.println(Messages.MatrixImpl_79);
+				org.txm.utils.logger.Log.printStackTrace(e);
+				return;
+			}
+			String lastRowName = rowNames[last];
+			System.out.println("table<-matrix(table[c(-"+idx+"),],nrow=1,dimnames = list(rownames="+lastRowName+",colnames(table)))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		} else {
+			System.out.println(Messages.MatrixImpl_88);
+		}
+	}
+
+	public void removeRows(List<Integer> rows, boolean removeEmptyCols) throws RWorkspaceException {
+		this.removeRows(rows);
+		if (removeEmptyCols) {
+			removeEmptyCols();
+		}
+	}
+
+	/**
+	 * Sets the.
+	 *
+	 * @param row the row
+	 * @param col the col
+	 * @param value the value
+	 */
+	public void set(int row, int col, double value) {
+		int nrow = this.getNRows();
+		int ncol = this.getNColumns();
+		if (row < 0 || row >= nrow) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_10 + row
+					+ Messages.MatrixImpl_11 + nrow + ")"); //$NON-NLS-1$ 
+		}
+		if (col < 0 || col >= ncol) {
+			throw new IllegalArgumentException(Messages.MatrixImpl_13 + col
+					+ Messages.MatrixImpl_14 + ncol + ")"); //$NON-NLS-1$ 
+		}
+		// appel à R
+		try {
+			REXP r = rw.eval(symbol
+					+ "[" + ArrayIndex.zeroToOneBasedIndex(row) + ", " + ArrayIndex.zeroToOneBasedIndex(col) + " ] <- " + value + ";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Sets the order.
+	 *
+	 * @param neworder the neworder
+	 * @param reverse the reverse
+	 */
+	public void setOrder(List<Integer> neworder, Boolean reverse) {
+		int nrow = this.getNRows();
+		if (neworder.size() != nrow)
+		{
+			//System.out.println("MatrixImpl.setOrder: error new order size "+neworder.size()+" != nrow "+nrow);
+			return;
+		}
+		String order = "c("; //$NON-NLS-1$
+		if (reverse) {
+			for (int i = neworder.size() - 1; i >= 0; i--)
+				order += "" + (neworder.get(i) + 1) + ", "; //$NON-NLS-1$ //$NON-NLS-2$
+		} else {
+			for (Integer i : neworder)
+				order += "" + (i + 1) + ", "; //$NON-NLS-1$ //$NON-NLS-2$
+		}
+		order = order.substring(0, order.length() - 2);
+					order += ")"; //$NON-NLS-1$
+					try {
+						// System.out.println("R sort rownames Reverse"+reverse);
+						REXP r = rw.eval(symbol + "<- " + symbol + "[" + order + ", ];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+						//REXP r2 = rw.eval("rownames("+symbol+") <- rownames(" + symbol + ")[" + order + "];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+					} catch (RWorkspaceException e) {
+						// TODO Auto-generated catch block
+						org.txm.utils.logger.Log.printStackTrace(e);
+					}
+	}
+
+	/**
+	 * Sort.
+	 *
+	 * @param col the col
+	 * @param reverse the reverse
+	 */
+	public void sort(int col, Boolean reverse) {
+		try {
+			// System.out.println("R sort "+col+" Reverse"+reverse);
+			REXP r = rw
+					.eval(symbol
+							+ "<- " + symbol + "[order(" + symbol + "[ ," + (col + 1) + "], decreasing = " + reverse.toString().toUpperCase() + "), ];;"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Sort row names.
+	 *
+	 * @param reverse the reverse
+	 */
+	public void sortRowNames(Boolean reverse) {
+
+		try {
+			// System.out.println("R sort rownames Reverse"+reverse);
+			REXP r = rw
+					.eval(symbol
+							+ "<- " + symbol + "[order(rownames(" + symbol + "), decreasing = " + reverse.toString().toUpperCase() + "), ];"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			getRowNames().sort(reverse);
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+
+	/**
+	 * Export data.
+	 *
+	 * @param f the f
+	 * @param colseparator the colseparator
+	 * @param txtseparator the txtseparator
+	 */
+	public void toTxt(File f, String encoding, String colseparator, String txtseparator) {
+		try {
+			String path = f.getAbsolutePath().replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
+			org.txm.stat.engine.r.RWorkspace.getRWorkspaceInstance().safeEval(
+					"write.table(" + symbol + ", file=\"" + path + "\""//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+							+ ", fileEncoding=\""+encoding+"\"" //$NON-NLS-1$ //$NON-NLS-2$
+							+ ", sep=\""+colseparator+"\");"); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (Exception e1) {
+			org.txm.utils.logger.Log.printStackTrace(e1);
+			RWorkspace.printLastSafeEvalExpr();
+		}
+	}
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/MatrixImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/RObjectAlreadyExist.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/RObjectAlreadyExist.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/RObjectAlreadyExist.java	(revision 219)
@@ -0,0 +1,79 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r.data;
+
+import org.txm.stat.engine.r.RWorkspaceException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * When one try to create an object with a symbol already existing in the
+ * workspace.
+ * 
+ * @author sloiseau
+ */
+public class RObjectAlreadyExist extends RWorkspaceException {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 3386015668080138287L;
+
+	/**
+	 * Instantiates a new r object already exist.
+	 */
+	public RObjectAlreadyExist() {
+		super();
+	}
+
+	/**
+	 * Instantiates a new r object already exist.
+	 *
+	 * @param arg0 the arg0
+	 * @param arg1 the arg1
+	 */
+	public RObjectAlreadyExist(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+	/**
+	 * Instantiates a new r object already exist.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RObjectAlreadyExist(String arg0) {
+		super(arg0);
+	}
+
+	/**
+	 * Instantiates a new r object already exist.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RObjectAlreadyExist(Throwable arg0) {
+		super(arg0);
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/RObjectAlreadyExist.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/ContingencyTableImpl.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/ContingencyTableImpl.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/ContingencyTableImpl.java	(revision 219)
@@ -0,0 +1,357 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r.data;
+
+import org.rosuda.REngine.REXPMismatchException;
+import org.txm.stat.StatException;
+import org.txm.stat.data.ContingencyTable;
+import org.txm.stat.data.Vector;
+import org.txm.stat.engine.r.RWorkspaceException;
+import cern.colt.matrix.DoubleMatrix2D;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Implementation of the {@link ContingencyTable} interface, wrapping a R
+ * matrix.
+ * 
+ * @author sloiseau
+ */
+public class ContingencyTableImpl extends MatrixImpl implements
+		ContingencyTable {
+
+	/**
+	 * Create a new contingency table after a {@link DoubleMatrix2D}.
+	 *
+	 * @param matrix the matrix
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public ContingencyTableImpl(DoubleMatrix2D matrix)
+			throws RWorkspaceException {
+		super(matrix);
+	}
+
+	/**
+	 * Create a new contingency table after a {@link DoubleMatrix2D}, with row
+	 * names and column names.
+	 *
+	 * @param matrix the matrix
+	 * @param rowNames row names.
+	 * @param columnNames the column names
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public ContingencyTableImpl(DoubleMatrix2D matrix, String[] rowNames,
+			String[] columnNames) throws RWorkspaceException {
+		super(matrix, rowNames, columnNames);
+	}
+
+	/**
+	 * Instantiates a new contingency table impl.
+	 *
+	 * @param matrix the matrix
+	 * @param formNames the form names
+	 * @param partNames the part names
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public ContingencyTableImpl(int[][] matrix, String[] formNames,
+			String[] partNames) throws RWorkspaceException {
+		super(matrix, formNames, partNames);
+	}
+	
+	/**
+	 * See {@link MatrixImpl#Matrix(String, Header)}.
+	 *
+	 * @param symbol the name of the object
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public ContingencyTableImpl(String symbol) throws RWorkspaceException {
+		super(symbol);
+	}
+
+
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.ContingencyTable#getColMargin()
+	 */
+	public Vector getColMargin() throws RWorkspaceException {
+		String colName = createSymbole(Vector.class);
+		rw.voidEval(colName + "<- colSums(" + this.symbol + ");"); //$NON-NLS-1$ //$NON-NLS-2$
+		return new VectorImpl(colName);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.ContingencyTable#getRowMargin()
+	 */
+	@Override
+	public Vector getRowMarginsVector() throws StatException {
+		String colName = createSymbole(Vector.class);
+		rw.voidEval(colName + "<- rowSums(" + this.symbol + ");"); //$NON-NLS-1$ //$NON-NLS-2$
+		return new VectorImpl(colName);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.ContingencyTable#getRowMargin()
+	 */
+	@Override
+	public Vector getColMarginsVector() throws StatException {
+		String rowName = createSymbole(Vector.class);
+		try {
+			rw.voidEval(rowName + "<- colSums(" + this.symbol + ");"); //$NON-NLS-1$ //$NON-NLS-2$
+			return new VectorImpl(rowName);
+		} catch (RWorkspaceException e) {
+			throw new StatException(e);
+		} 
+		
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.txm.stat.data.ContingencyTable#getTotal()
+	 */
+	@Override
+	public int getTotal() throws RWorkspaceException {
+		int total;
+		try {
+			total = rw.eval("sum(" + this.symbol + ");").asInteger(); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+		return total;
+	}
+
+	// /**
+	// * Gets the col.
+	// *
+	// * @param index the index
+	// *
+	// * @return the col
+	// */
+	// public DoubleMatrix1D getCol(int index) {
+	// if (index < 0 || index >= matrix.columns()) {
+	// throw new IllegalArgumentException("Column index (" + index +
+	// ") too hight (max: " + matrix.columns() + ")");
+	// }
+	// return matrix.viewColumn(index);
+	// }
+	//
+	// /**
+	// * Gets the sum.
+	// *
+	// * @return the sum
+	// */
+	// public int getSum() {
+	// if (sum == -1) {
+	// sum = (int) this.matrix.zSum();
+	// }
+	// return sum;
+	// }
+	//
+	//	
+	// /**
+	// * Row margin.
+	// *
+	// * @return the sum over the rows
+	// */
+	// public DoubleMatrix1D getRowSum() {
+	// if (rowSum==null){
+	// DoubleMatrix1D ones = DoubleFactory1D.dense.make(matrix.rows(),1);
+	// rowSum = matrix.viewDice().zMult(ones, null);
+	// }
+	// return rowSum;
+	// }
+	//	
+	//
+	//
+	// /**
+	// * Col margin.
+	// *
+	// * @return the sum over the columns
+	// */
+	// public DoubleMatrix1D getColSum() {
+	// if (colSum==null){
+	// DoubleMatrix1D ones = DoubleFactory1D.dense.make(matrix.columns(),1);
+	// colSum = matrix.zMult(ones, null);
+	// }
+	// return colSum;
+	// }
+
+	/**
+	 * Apply a four paramters-function on the whole table.
+	 * 
+	 * For each non zero value, the function will received four parameters:
+	 * <ul>
+	 * <li>The sum of the values in the matrix</li>
+	 * <li>The sum of the row of the given value</li>
+	 * <li>The sum of the column of the given value</li>
+	 * <li>The value</li>
+	 * </ul>
+	 * 
+	 * @param fun
+	 *            the fun
+	 * 
+	 * @return the matrix
+	 */
+	// public Matrix apply(final AbstractMatrixIntIntIntDoubleFunction fun) {
+	// cacheColSum();
+	// cacheRowSum();
+	// cacheSum();
+	// return new Matrix(
+	// matrix.copy().forEachNonZero(
+	// new IntIntDoubleFunction() {
+	// public double apply(int row, int col, double value) {
+	// return fun.apply(sum, rowSum[row], colSum[col], value);
+	// }
+	// }
+	// )
+	// );
+	// }
+
+	/**
+	 * Apply a function on the given row.
+	 * 
+	 * For each non zero value, the function will received four parameters:
+	 * <ul>
+	 * <li>The sum of the values in the matrix</li>
+	 * <li>The sum of the row of the given value</li>
+	 * <li>The sum of the column of the given value</li>
+	 * <li>The value</li>
+	 * </ul>
+	 * 
+	 * @param fun
+	 *            the fun
+	 * @param rowIndex
+	 *            the row index
+	 * 
+	 * @return the variable
+	 */
+	// public NumericalVector applyOnRowWithMargin(final
+	// AbstractMatrixIntIntIntDoubleFunction fun, int rowIndex) {
+	// cacheColSum();
+	// cacheRowSum();
+	// cacheSum();
+	// IntArrayList indexList = new IntArrayList();
+	// DoubleArrayList valueList = new DoubleArrayList();
+	// matrix.viewRow(rowIndex).getNonZeros(indexList, valueList);
+	//
+	// DoubleArrayList result = new DoubleArrayList(indexList.size());
+	//
+	// for (int i = 0; i < indexList.size(); i++) {
+	// int column = indexList.getQuick(i);
+	// double value = valueList.getQuick(i);
+	// result.setQuick(i, fun.apply(sum, rowSum[rowIndex], colSum[column],
+	// value));
+	// }
+	//
+	// return new NumericalVector(result);
+	// }
+
+	/**
+	 * Apply a function on the given column.
+	 * 
+	 * For each non zero value, the function will received four parameters:
+	 * <ul>
+	 * <li>The sum of the values in the matrix</li>
+	 * <li>The sum of the row of the given value</li>
+	 * <li>The sum of the column of the given value</li>
+	 * <li>The value</li>
+	 * </ul>
+	 * 
+	 * @param fun
+	 *            the fun
+	 * @param columnIndex
+	 *            the column index
+	 * 
+	 * @return the variable
+	 */
+	// public NumericalVector applyOnColumnWithMargin(final
+	// AbstractMatrixIntIntIntDoubleFunction fun, int columnIndex) {
+	// cacheColSum();
+	// cacheRowSum();
+	// cacheSum();
+	// IntArrayList indexList = new IntArrayList();
+	// DoubleArrayList valueList = new DoubleArrayList();
+	// matrix.viewColumn(columnIndex).getNonZeros(indexList, valueList);
+	//
+	// DoubleArrayList result = new DoubleArrayList(indexList.size());
+	//
+	// for (int i = 0; i < indexList.size(); i++) {
+	// int row = indexList.getQuick(i);
+	// double value = valueList.getQuick(i);
+	// result.setQuick(i, fun.apply(sum, rowSum[row], colSum[columnIndex],
+	// value));
+	// }
+	// return new NumericalVector(result);
+	// }
+
+	// /**
+	// * For each non zero value in the matrix, get its row in the
+	// * first list, its column in the second list, and its value
+	// * in the third list.
+	// *
+	// * This is a strict delegation to {@link
+	// DoubleMatrix2D#getNonZeros(IntArrayList, IntArrayList, DoubleArrayList)}.
+	// *
+	// * @param rowList
+	// * @param columnList
+	// * @param valueList
+	// */
+	// public void getNonZeros(IntArrayList rowList, IntArrayList columnList,
+	// DoubleArrayList valueList) {
+	// matrix.getNonZeros(rowList, columnList, valueList);
+	// }
+
+	/**
+	 * For each non zero value in the matrix, get its row in the first list, its
+	 * column in the second list, its value in the third list, the total of the
+	 * column of the value in the fourth list, and the total of the row of the
+	 * value in the firth list.
+	 * 
+	 * @param rowList
+	 * @param columnList
+	 * @param valueList
+	 * @param columnMargin
+	 * @param rowMargin
+	 */
+	// public void getNonZerosWithMargin(
+	// IntArrayList rowList,
+	// IntArrayList columnList,
+	// DoubleArrayList valueList,
+	// IntArrayList columnMargin,
+	// IntArrayList rowMargin
+	// ) {
+	// I'm not sure to understand what this function does, but I'm pretty sure
+	// it's buggy
+	// cacheColSum();
+	// cacheRowSum();
+	// matrix.getNonZeros(rowList, columnList, valueList);
+	// columnMargin.setSize(rowList.size());
+	// rowMargin.setSize(rowList.size());
+	// for (int i = 0; i < rowList.size(); i++) {
+	// columnMargin.setQuick(i, colSum[columnList.getQuick(i)]);
+	// rowMargin.setQuick(i, rowSum[rowList.getQuick(i)]);
+	// }
+	// }
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/ContingencyTableImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/data/QuantitativeDataStructureImpl.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/data/QuantitativeDataStructureImpl.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/data/QuantitativeDataStructureImpl.java	(revision 219)
@@ -0,0 +1,204 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r.data;
+
+import org.rosuda.REngine.REXP;
+import org.txm.stat.data.QuantitativeDataStructure;
+import org.txm.stat.data.Vector;
+import org.txm.stat.engine.r.RWorkspace;
+import org.txm.stat.engine.r.RWorkspaceException;
+import org.txm.Messages;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The root of the hierarchy for all classes wrapping R data.
+ * 
+ * @author Sylvain Loiseau &lt;sloiseau@ens-lsh.fr&gt;
+ */
+public abstract class QuantitativeDataStructureImpl implements
+		QuantitativeDataStructure {
+	
+	/** The counter. */
+	private static int counter = 1;
+
+	/**
+	 * An immutable symbol for the name of this data structure in the R
+	 * workspace.
+	 */
+	protected String symbol;
+
+	/** The R workspace. */
+	protected final RWorkspace rw;
+
+	/**
+	 * This constructor is called by every sub-classes for initializing final
+	 * fields header and symbol.
+	 *
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	protected QuantitativeDataStructureImpl() throws RWorkspaceException {
+		this.symbol = createSymbole();
+		this.rw = RWorkspace.getRWorkspaceInstance();
+	}
+
+	/**
+	 * This constructor is called by every sub-classes for initializing final
+	 * fields header and symbol.
+	 *
+	 * @param symbol the symbol
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	protected QuantitativeDataStructureImpl(String symbol)
+			throws RWorkspaceException {
+		this.rw = RWorkspace.getRWorkspaceInstance();
+		/*if (!rw.containsVariable(symbol)) {
+			throw new RObjectDoesNotExist(
+					Messages.QuantitativeDataStructureImpl_0 + symbol
+							+ Messages.QuantitativeDataStructureImpl_1);
+		}*/
+		this.symbol = symbol;
+	}
+
+	/**
+	 * Create an arbitrary symbol for naming this quantitative data structure
+	 * into the R workspace.
+	 * 
+	 * @return a symbol.
+	 */
+	protected final String createSymbole() {
+		return createSymbole(getClass());
+	}
+
+	/**
+	 * Create an arbitrary symbol for naming this quantitative data structure
+	 * into the R workspace given a class name.
+	 *
+	 * @param aClass the a class
+	 * @return the symbol.
+	 */
+	public final static String createSymbole(Class<?> aClass) {
+		int hash = counter++;
+		// warning : always use the absolute value since the hashCode may
+		// be a negative value; if turned into string, a negative value will
+		// start with "-"
+		// and produce an illegal R variable name. SL, 2009 05 22.
+		String prefix = aClass.getSimpleName();
+		if (prefix.endsWith("Impl")) //$NON-NLS-1$
+			prefix = prefix.substring(0, prefix.length()-4);
+		String s = prefix + String.valueOf(hash);
+		return s;
+	}
+
+	/**
+	 * Remove the object from the R workspace.
+	 *
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	protected void removeFromRWorkspace() throws RWorkspaceException {
+		if (!rw.containsVariable(symbol)) {
+			throw new RObjectDoesNotExist(
+					Messages.QuantitativeDataStructureImpl_2);
+		}
+		rw.voidEval("rm(" + symbol + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	// @Override
+	// /**
+	// * Provide information about the header of this object and basic snapshot
+	// of its content using the <code>str</code> R function.
+	// */
+	// public String toString() {
+	// StringBuffer sb = new StringBuffer();
+	// sb.append(header.toString());
+	// // String representation = "";
+	// // try {
+	// // NO
+	// // representation = rw.eval("str(" + symbol + ")").toString();
+	// // } catch (REXPMismatchException e) {
+	// // representation = " [No representation available for this object.]";
+	// // } catch (RWorkspaceException e) {
+	// // representation = " [No representation available for this object.]";
+	// // }
+	// return sb.toString();
+	// }
+
+	/**
+	 * Add the given key-value attribute pair to the wrapped R object.
+	 *
+	 * @param name the name
+	 * @param vals the vals
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	protected void setAttribute(String name, String[] vals)
+			throws RWorkspaceException {
+		Vector attr = new VectorImpl(vals);
+
+		StringBuffer exp = new StringBuffer();
+		exp.append("attr("); //$NON-NLS-1$
+		exp.append(symbol);
+		exp.append(","); //$NON-NLS-1$
+		exp.append(name);
+		exp.append(")"); //$NON-NLS-1$
+		exp.append("<-"); //$NON-NLS-1$
+		exp.append(attr.getSymbol());
+		exp.append(";"); //$NON-NLS-1$
+
+		rw.voidEval(exp.toString());
+		rw.voidEval("rm(" + attr.getSymbol() + ");"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	/**
+	 * Get an attribute on a R object.
+	 *
+	 * @param name of the attribute
+	 * @return the attribute as a REXP object, since the attribute may be every
+	 * data type.
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	protected REXP getAttribute(String name) throws RWorkspaceException {
+		StringBuffer exp = new StringBuffer();
+		exp.append("attr("); //$NON-NLS-1$
+		exp.append(symbol);
+		exp.append(","); //$NON-NLS-1$
+		exp.append(name);
+		exp.append(")"); //$NON-NLS-1$
+		exp.append(";"); //$NON-NLS-1$
+
+		return rw.eval(exp.toString());
+	}
+
+	/**
+	 * Gets the symbol, ie. the name of the data structure in R.
+	 * 
+	 * @return the symbol
+	 */
+	@Override
+	public String getSymbol() {
+		return symbol;
+	}
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/data/QuantitativeDataStructureImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/RConstant.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/RConstant.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/RConstant.java	(revision 219)
@@ -0,0 +1,47 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class RConstant.
+ */
+public class RConstant {
+	
+	/** The Constant LIST_EXTRACTOR. */
+	public final static String LIST_EXTRACTOR = "$"; //$NON-NLS-1$
+	
+	/** The Constant OPEN_PAREN. */
+	public final static String OPEN_PAREN = "("; //$NON-NLS-1$
+	
+	/** The Constant CLOSE_PAREN. */
+	public final static String CLOSE_PAREN = ")"; //$NON-NLS-1$
+	
+	/** The Constant AFFECTATION. */
+	public final static String AFFECTATION = "<-"; //$NON-NLS-1$
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/RConstant.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/package.html
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/package.html	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/package.html	(revision 219)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Root package of the implementation of a stat engine using the R piece of software (<a href="http://www.r-project.org">http://www.r-project.org</a>.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/RWorkspaceException.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/RWorkspaceException.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/RWorkspaceException.java	(revision 219)
@@ -0,0 +1,82 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r;
+
+import org.txm.stat.StatException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Super-class of all exception related to the R engine.
+ * 
+ * @author sloiseau
+ */
+public class RWorkspaceException extends StatException {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1630828823146927953L;
+
+	/**
+	 * Instantiates a new r workspace exception.
+	 */
+	public RWorkspaceException() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new r workspace exception.
+	 *
+	 * @param arg0 the arg0
+	 * @param arg1 the arg1
+	 */
+	public RWorkspaceException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new r workspace exception.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RWorkspaceException(String arg0) {
+		super(arg0);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new r workspace exception.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RWorkspaceException(Throwable arg0) {
+		super(arg0);
+		// TODO Auto-generated constructor stub
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/RWorkspaceException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/RException.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/RException.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/RException.java	(revision 219)
@@ -0,0 +1,89 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (Mon, 06 May 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r;
+
+import org.txm.Messages;
+
+// TODO: Auto-generated Javadoc
+/**
+ * An exception indicating an error during the evaluation of an expression by
+ * the R engine.
+ * 
+ * @author sloiseau
+ */
+public class RException extends RWorkspaceException {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = -3459835604570896478L;
+
+	/**
+	 * Instantiates a new r exception.
+	 */
+	public RException() {
+		super();
+	}
+
+	/**
+	 * Instantiates a new r exception.
+	 *
+	 * @param msg the msg
+	 */
+	public RException(String msg) {
+		super(msg);
+	}
+
+	/**
+	 * Instantiates a new r exception.
+	 *
+	 * @param expr the expr
+	 * @param msg the msg
+	 */
+	public RException(String expr, String msg) {
+		super(Messages.RException_0 + msg + Messages.RException_1 + Messages.RException_2 + expr); 
+	}
+
+	/**
+	 * Instantiates a new r exception.
+	 *
+	 * @param arg0 the arg0
+	 * @param arg1 the arg1
+	 */
+	public RException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+	/**
+	 * Instantiates a new r exception.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public RException(Throwable arg0) {
+		super(arg0);
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/RException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/engine/r/RWorkspace.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/engine/r/RWorkspace.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/engine/r/RWorkspace.java	(revision 219)
@@ -0,0 +1,1530 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2015-06-15 15:29:16 +0200 (Mon, 15 Jun 2015) $
+// $LastChangedRevision: 2989 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.engine.r;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.UUID;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.internal.util.BundleUtility;
+import org.osgi.framework.Bundle;
+import org.rosuda.REngine.REXP;
+import org.rosuda.REngine.REXPLogical;
+import org.rosuda.REngine.REXPMismatchException;
+import org.rosuda.REngine.REngineException;
+import org.rosuda.REngine.Rserve.RConnection;
+import org.rosuda.REngine.Rserve.RserveException;
+import org.txm.Messages;
+import org.txm.stat.StatException;
+import org.txm.stat.data.QuantitativeDataStructure;
+import org.txm.stat.engine.r.data.RObjectAlreadyExist;
+import org.txm.stat.engine.r.rcolt.RColt;
+import org.txm.stat.utils.VectorizeArray;
+import org.txm.utils.OSDetector;
+import org.txm.utils.StreamHog;
+import org.txm.utils.SystemProxyDetector;
+import org.txm.utils.logger.Log;
+
+import cern.colt.list.DoubleArrayList;
+import cern.colt.list.IntArrayList;
+import cern.colt.matrix.DoubleMatrix2D;
+
+// TODO: Auto-generated Javadoc
+/**
+ * RWorkspace is the wrapper on top of the R Engine. All data sent to and
+ * retreive from R are using this class. One instance of this class must be
+ * created in a program.
+ * 
+ * This class throw exception RWorkspace exception, encapsulating lower level
+ * exception such as <code>RserveException</code>,
+ * <code>REXPMismatchException</code> or <code>REngineException</code>.
+ * 
+ * This class offers many methods avoiding other classes in the toolbox to
+ * contain R code. The goal is to concentrate R code, as much as possible, here.
+ * See {@link #extractItemFromListByName(String, String)} for instance, and
+ * other "extract..." methods.
+ * 
+ * methods in this class may be organized in the following group:
+ * <ul>
+ * <li>1/ initialization, connection to R, shutdown, etc.</li>
+ * <li>2/ adding object to the R workspace (methods prefixed with "add").</li>
+ * <li>3/ methods encapsulating R code for common fonctions: methods prefixed
+ * with "assign...", "extract..." for instance.</li>
+ * <li>4/ methods for evaluating R expression ({@link #safeEval(String)},
+ * {@link #eval(String)}, {@link #evalToDouble(String)}, etc.)</li>
+ * <li>5/ Static methods for converting result of evaluation in type (
+ * {@link #toDouble(REXP)}, etc.)</li>
+ * <li>6/ methods for checking existence of R object in the R workspace,
+ * removing object from the R workspace, etc.
+ * {@link #checkForDuplicateVariable(String)}, {@link #clearWorkspace()},
+ * {@link #containsVariable(String)},
+ * {@link #removeVariableFromWorkspace(String)}, etc.)</li>
+ * <li>7/ methods for plotting.</li>
+ * </ul>
+ * 
+ * TODO : assign/remove... in a textometrie environment, when Rengine.assign()
+ * will be able to deal with R environment.
+ * 
+ * TODO : remove unused variables from workspace.
+ * 
+ * @author Sylvain Loiseau &lt;sloiseau@ens-lsh.fr&gt;
+ */
+
+public final class RWorkspace {
+
+	/** The comm. */
+	private static RFileCommunication comm;
+
+	/** The connection. */
+	private static RConnection connection = null;
+
+	/** The eval logs. */
+	static ArrayList<String> evalLogs = new ArrayList<String>();
+
+	/** The filecommunication. */
+	private static boolean filecommunication = false;
+
+	// --------------------------------------
+	/** The last safeeval expr. */
+	static String lastSafeevalExpr = ""; //$NON-NLS-1$
+
+	/** The Rserve process. */
+	private static Process RserveProcess = null;
+
+	/** The workspace. */
+	private static RWorkspace workspace = null;
+	
+	/** The error logger. */
+	private StreamHog errorLogger;
+
+	/** The input logger. */
+	private StreamHog inputLogger;
+
+	/** The loggin. */
+	private boolean logging;
+
+	/** The DEFAUL t_ symbol. */
+	//private String DEFAULT_SYMBOL = "txmresult"; //$NON-NLS-1$
+
+	/**
+	 * Folder where to create the R working directory
+	 */
+	protected File userdir = null;
+
+	/**
+	 * Appendto eval log.
+	 *
+	 * @param cmd the cmd
+	 */
+	public static void appendtoEvalLog(String cmd)
+	{
+		evalLogs.add(cmd);
+	}
+
+	/**
+	 * Close the connection.
+	 *
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public static final void closeConnection() throws RWorkspaceException {
+		// If no R object have been created during the lif ecycle of the
+		// application,
+		// the connection has never been initialized.
+		if (connection != null)
+			connection.close();
+	}
+
+	/**
+	 * Connect to Rserve.
+	 *
+	 * @param host the host
+	 * @param port the port
+	 * @return true if success
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public static boolean connect(String host, int port)
+			throws RWorkspaceException {
+		try {
+			Log.info(Messages.RWorkspace_2+host+":"+port); //$NON-NLS-1$
+			connection = new RConnection(host, port);
+			//connection.setStringEncoding("UTF-8");
+
+			return isConnected();
+		} catch (RserveException x) {
+			throw new RWorkspaceException(x);
+		}
+
+	}
+
+	/**
+	 * Connect to Rserve.
+	 *
+	 * @param host the host
+	 * @param port the port
+	 * @param user the user
+	 * @param password the password
+	 * @return true, if successful
+	 */
+	public static boolean connect(String host, int port, String user,
+			String password) {
+		try {
+			Log.info(Messages.RWorkspace_2+host+":"+port+" user :"+user); //$NON-NLS-2$ //$NON-NLS-1$
+			connection = new RConnection(host, port);
+			connection.login(user, password);
+			return isConnected();
+
+		} catch (RserveException x) {
+			System.out.println(Messages.RWorkspace_0 + host+ ", " + port + ", " + user); //$NON-NLS-1$//$NON-NLS-2$ 
+			Log.severe(Messages.RWorkspace_0 + host+ ", " + port + ", " + user); //$NON-NLS-1$//$NON-NLS-2$ 
+		}
+		return false;
+	}
+
+	/**
+	 * Gets the last safe eval expr.
+	 *
+	 * @return the last safe eval expr
+	 */
+	public static String getLastSafeEvalExpr()
+	{
+		return lastSafeevalExpr;
+	}
+
+
+	public static String getRandomSymbol() {
+		String symbol = "Random"+UUID.randomUUID(); //$NON-NLS-1$
+		return symbol;
+	}
+
+	/**
+	 * Entering the R workspace.
+	 *
+	 * @param 
+	 * @return the r workspace instance
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public static final RWorkspace getRWorkspaceInstance()
+			throws RWorkspaceException {
+		Bundle bundle = Platform.getBundle("org.txm.r");
+		File userdir = new File(bundle.getLocation());
+		System.out.println("BUNDLE LOCATION OF 'org.txm.r': "+userdir);
+		if (workspace == null) {
+			workspace = new RWorkspace(userdir);
+		}
+		return workspace;
+	}
+
+	/**
+	 * Post initialisation of Rserve : loads libraries.
+	 * @deprecated The extensions will load themself the packages they need 
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	private static void init() throws RWorkspaceException {
+		String[] packagesToLoad = { }; //$NON-NLS-1$
+		for (int i = 0; i < packagesToLoad.length; i++) {
+			String name = packagesToLoad[i];
+			try {
+				// System.out.println("load R lib : " + name);
+				connection.eval(("library(" + name + ")")); //$NON-NLS-1$ //$NON-NLS-2$
+				// System.out.println("Done : load R lib : " + name);
+			} catch (RserveException e) {
+				throw new RWorkspaceException(NLS.bind(Messages.LIBBRARY_NOT_LOADED, name, e));
+			} catch (Exception e) {
+				org.txm.utils.logger.Log.printStackTrace(e);
+			}
+		}
+	}
+
+	/**
+	 * Default initialisation of RWorkspace with defautl parameters :
+	 * address = 127.0.0.1
+	 * port = 6311
+	 * debug = false.
+	 *
+	 * @param pathToRExecutalbe the path to r executalbe
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public static final void initializeRWorkspace(String pathToRExecutalbe)
+			throws RWorkspaceException {
+		workspace = new RWorkspace(pathToRExecutalbe, "127.0.0.1", 6311, false); //$NON-NLS-1$
+	}
+
+	/**
+	 * Initialize r workspace.
+	 * debug = false
+	 *
+	 * @param pathToRExecutalbe the path to r executalbe
+	 * @param host the host
+	 * @param port the port
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public static final void initializeRWorkspace(String pathToRExecutalbe,
+			String host, int port) throws RWorkspaceException {
+		workspace = new RWorkspace(pathToRExecutalbe, host, port, false);
+	}
+
+	// --------------------------------------
+	/**
+	 * check R path
+	 * check if Rserve has already been launched
+	 * if not try to launch it.
+	 *
+	 * @param pathToRExecutable the path to r executable
+	 * @param options 
+	 * @param rServeArgs 
+	 * @return true if Rserve is launched
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	private static boolean initRserve(String pathToRExecutable, int port, boolean debug, String rargs, String rServeArgs)
+			throws RWorkspaceException {
+		boolean isRServerOk;
+		if (pathToRExecutable == null || pathToRExecutable.length() == 0) {
+			isRServerOk = StartRserve.checkLocalRserve(port, debug, rargs, rServeArgs);
+			if (!isRServerOk) {
+				throw new RWorkspaceException(
+						Messages.RSERVE_PATH_NOT_SET_ERROR); 
+			}
+		} else {
+			Log.info(Messages.RWorkspace_10+pathToRExecutable);
+			isRServerOk = StartRserve.launchRserve(pathToRExecutable, port, debug, rargs, rServeArgs);
+			// System.out.println("ap launchRserve");
+			if (!isRServerOk) {
+				throw new RWorkspaceException(Messages.RSERVE_PATH_SET_ERROR+ " : "+pathToRExecutable); //$NON-NLS-1$
+			}
+		}
+
+		if (isRServerOk) {
+			Log.finest("RSERVE_ACTIVATED"); //$NON-NLS-1$
+			System.out.println(Messages.CONNECTED_TO_STATS_MODULE); 
+			RserveProcess = StartRserve.Rserveprocess;
+		}
+		return isRServerOk;
+	}
+
+	/**
+	 * Checks if is connected.
+	 *
+	 * @return true if the RWorkspace is connected to RServe
+	 */
+	private static boolean isConnected() {
+		if (!connection.isConnected()) {
+			return false;
+		} else {
+			return true;
+		}
+	}
+
+	
+	/**
+	 * Checks if is file tranfert.
+	 *
+	 * @return true, if is file tranfert
+	 */
+	public static boolean isFileTranfert() {
+		return filecommunication;
+	}
+
+	
+	
+	/**
+	 * Load eval log.
+	 *
+	 * @param file the file
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static void loadEvalLog(File file) throws IOException
+	{
+		BufferedReader reader = new BufferedReader(new FileReader(file));
+		String cmd = reader.readLine();
+		while(cmd != null)
+		{
+			evalLogs.add(cmd);
+			cmd = reader.readLine();
+		}
+		reader.close();
+	}
+
+	/**
+	 * Prints the last safe eval expr.
+	 */
+	public static void printLastSafeEvalExpr() {
+		System.out.println(Messages.RWorkspace_11+lastSafeevalExpr);
+	}
+
+	/**
+	 * Save eval log.
+	 *
+	 * @param file the file
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static void saveEvalLog(File file) throws IOException {
+		FileWriter writer = new FileWriter(file);
+		for (String cmd : evalLogs)
+			writer.write(cmd+"\n"); //$NON-NLS-1$
+		writer.flush();
+		writer.close();
+	}
+
+	/**
+	 * if state is true, the matrix will be send to R with a File.
+	 *
+	 * @param state the state
+	 * @return true if success
+	 */
+	public static boolean setUseFileCommunication(boolean state) {
+		filecommunication = state;
+		if (filecommunication) {
+			try {
+				comm = new RFileCommunication();
+			} catch (IOException e) {
+				filecommunication = false;
+				Log.severe(Messages.RWorkspace_6+Log.toString(e));
+				return false;
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Close the connection and destroy the Rserve process.
+	 *
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public static final void shutdown() throws RWorkspaceException {
+		try {
+			// If no R object have been created during the lif ecycle of the
+			// application,
+			// the connection has never been initialized.
+
+			if (connection != null) {
+				if (connection.isConnected()) {
+					// connection.close(); // No: invoquing "close()" make
+					// "shutdown()" to throw a "not connected" exception.
+					connection.shutdown();
+					connection = null; // warning, after shuting down the
+					// server, the connection appears still
+					// ok but using it yield to a
+					// "Broken pipe" exception.
+				}
+			}
+			if (RserveProcess != null) RserveProcess.destroy();
+		} catch (RserveException e) {
+			throw new RWorkspaceException(e);
+		}
+	}
+
+	/**
+	 * Start exec.
+	 *
+	 * @param pathToRExecutable the path to r executable
+	 * @param string 
+	 * @param string 
+	 * @return true, if successful
+	 */
+	public static boolean startExec(String pathToRExecutable, int port, boolean debug, String rArgs, String rServeArgs) {
+		// System.out.println("Start Exec");
+		try {
+			initRserve(pathToRExecutable, port, debug, rArgs, rServeArgs);
+			return true;
+		} catch (RWorkspaceException e) {
+			System.out.println(Messages.RWorkspace_8+e);
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		return false;
+	}
+
+	/**
+	 * To double.
+	 *
+	 * @param rexp the rexp
+	 * @return the double[]
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public static final double[] toDouble(REXP rexp) throws RWorkspaceException {
+		try {
+			return rexp.asDoubles();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+	}
+
+	/**
+	 * protected on purpose. See {@link #getRWorkspaceInstance()}.
+	 *
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public RWorkspace(File userdir) throws RWorkspaceException {
+		this.userdir = userdir;
+	}
+
+	// --------------------------------------
+
+//	/**
+//	 * protected on purpose. See {@link #getRWorkspaceInstance()}.
+//	 *
+//	 * @param pathToRExecutable the path to r executable
+//	 * @throws RWorkspaceException the r workspace exception
+//	 */
+//	protected RWorkspace(String pathToRExecutable, int port, boolean debug) throws RWorkspaceException {
+//		if (initRserve(pathToRExecutable, port, debug, "","")) {
+//			connect();
+//			init();
+//		}
+//	}
+
+	/**
+	 * protected on purpose. See {@link #getRWorkspaceInstance()}.
+	 *
+	 * @param pathToRExecutable the path to r executable
+	 * @param host the host
+	 * @param port the port
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	protected RWorkspace(String pathToRExecutable, String host, int port, boolean debug)
+			throws RWorkspaceException {
+		if (initRserve(pathToRExecutable, port, debug, "", "")) {
+			connect(host, port);
+			init();
+		}
+	}
+
+	/**
+	 * Add a matrix into the workspace and link it to a name. The inner arrays
+	 * of the <code>matrix</code> parameters are the <strong>row</strong> of the
+	 * resulting R matrix.
+	 *
+	 * @param variableName the name to be used in the R workspace.
+	 * @param matrix the data to be bound to the name. In the form
+	 * <code>matrix[row][column]</code>, with exactly the same number
+	 * of column in every row.
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void addMatrixToWorkspace(String variableName, double[][] matrix)
+			throws RWorkspaceException {
+		//System.out.println("matrix len: "+matrix.length+" test="+(matrix.length == 0));
+		if (matrix.length == 0) {
+			new RWorkspaceException(Messages.RWorkspace_7);
+		}
+		int ncol = matrix[0].length;
+		int nrow = matrix.length;
+
+		double[] vector = VectorizeArray.vectorizeByInner(matrix);
+
+		if (!filecommunication) {
+			try {
+				connection.assign(variableName, vector);
+			} catch (REngineException e) {
+				throw new RWorkspaceException(e);
+			}
+			try {
+				connection .voidEval(variableName
+						+ "<- matrix(" + variableName + ", nrow=" + nrow + ", ncol=" + ncol + ", byrow=T)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			} catch (RserveException e) {
+				throw new RWorkspaceException(e);
+			}
+		} else {
+			comm.assign(variableName, vector, nrow, ncol);
+		}
+		Log.finest("MATRIX_ADDED_TO_WORKSPACE" + new Object[] { nrow, ncol, variableName }); //$NON-NLS-1$
+	}
+
+	/**
+	 * Add a matrix into the workspace and link it to a name. Intended to be
+	 * efficient for sparse matrix.
+	 *
+	 * @param variableName the name to be used in the R workspace.
+	 * @param matrix the data to be bound to the name.
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void addMatrixToWorkspace(String variableName, DoubleMatrix2D matrix)
+			throws RWorkspaceException {
+
+		double[][] data = RColt.doubleMatrix2D2DoubleDoubleArray(matrix);
+		addMatrixToWorkspace(variableName, data);
+
+		// // IntArrayList x = new IntArrayList();
+		// // IntArrayList y = new IntArrayList();
+		// // DoubleArrayList val = new DoubleArrayList();
+		// //
+		// // matrix.trimToSize();
+		// // matrix.getNonZeros(x, y, val);
+		// // x.trimToSize();
+		// // y.trimToSize();
+		// // val.trimToSize();
+		// //
+		// // for (int i = 0; i < x.size(); i++) {
+		// // x.setQuick(i, x.getQuick(i) + 1);
+		// // }
+		// //
+		// // for (int i = 0; i < y.size(); i++) {
+		// // y.setQuick(i, y.getQuick(i) + 1);
+		// // }
+		// //
+		// // System.out.println("colt");
+		// // System.out.println(x);
+		// // System.out.println(y);
+		// // System.out.println(val);
+		//		
+		// int nrow = matrix.rows();
+		// int ncol = matrix.columns();
+		// // System.out.println(matrix);
+		// // System.out.println(Arrays.toString(vald));
+		// try {
+		// // connection.eval(variableName + "<- matrix(0, nrow=" + nrow +
+		// ", ncol=" + ncol + " );");
+		// connection.assign(variableName, m);
+		// } catch (RserveException e) {
+		// throw new RWorkspaceException(e);
+		// }
+		// try {
+		// connection.assign(variableName + ".nonzero", val.elements());
+		// connection.assign(variableName + ".x", x.elements());
+		// connection.assign(variableName + ".y", y.elements());
+		// } catch (REngineException e) {
+		// throw new RWorkspaceException(e);
+		// }
+		// try {
+		// // connection.voidEval("dim(" + variableName + ") <- c(" + nrow +
+		// ", " + ncol + ")");
+		// // connection.voidEval(variableName + "[" + variableName + ".x, " +
+		// variableName + ".y" + " ] <- " + variableName + ".nonzero");
+		// // for (int i = 0; i < x.size(); i++) {
+		// // for (int j = 0; j < y.size(); j++) {
+		// // connection.voidEval(variableName + "[" + x.getQuick(i) + ", " +
+		// y.getQuick(j) + "] <- " + val.getQuick(i * 5 + * j));
+		// // }
+		// // }
+		//			
+		// } catch (RserveException e) {
+		// throw new RWorkspaceException(e);
+		// }
+		//		
+		// removeVariableFromWorkspace(variableName + ".nonzero");
+		// removeVariableFromWorkspace(variableName + ".x");
+		// removeVariableFromWorkspace(variableName + ".y");
+		//		
+		//		
+		// System.out.println("--------------matrice d'origine----------");
+		// System.out.println(matrix);
+		//		
+		// // DoubleFactory2D.dense.make(arg0)
+		// System.out.println("--------------matrice issue de R----------");
+		// DenseDoubleMatrix2D m = null;
+		// try {
+		// m = new
+		// DenseDoubleMatrix2D(connection.eval(variableName).asDoubleMatrix());
+		// } catch (REXPMismatchException e) {
+		// // TODO Auto-generated catch block
+		// org.txm.utils.logger.Log.printStackTrace(e);
+		// } catch (RserveException e) {
+		// // TODO Auto-generated catch block
+		// org.txm.utils.logger.Log.printStackTrace(e);
+		// }
+		// System.out.println(m);
+
+	}
+
+//TODO: is addLexiconToWorkspace used ?
+//	/**
+//	 * Adds the lexicon to workspace.
+//	 *
+//	 * @param variableName the variable name
+//	 * @param lexicon the lexicon
+//	 * @throws RWorkspaceException the r workspace exception
+//	 */
+//	public void addLexiconToWorkspace(String variableName, Lexicon lexicon)
+//			throws RWorkspaceException {
+//		int[] freqs = lexicon.getFreq();
+//		String[] forms = lexicon.getForms();
+//		try {
+//			addVectorToWorkspace(variableName, freqs);
+//			addVectorToWorkspace(variableName + "_names", forms); //$NON-NLS-1$
+//			connection
+//			.voidEval("names(" + variableName + ") <- " + variableName + "_names"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+//			connection.voidEval("rm(" + variableName + "_names" + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+//		} catch (RserveException e) {
+//			throw new RWorkspaceException(e);
+//		}
+//		Log.finest("LEXICON_ADDED" + new Object[] { lexicon.nbrOfType() + variableName }); //$NON-NLS-1$
+//	}
+
+	/**
+	 * Add a matrix into the workspace and link it to a name. The inner arrays
+	 * of the <code>matrix</code> parameters are the <strong>row</strong> of the
+	 * resulting R matrix.
+	 *
+	 * @param variableName the name to be used in the R workspace.
+	 * @param matrix the data to be bound to the name. In the form
+	 * <code>matrix[row][column]</code>, with exactly the same number
+	 * of column in every row.
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void addMatrixToWorkspace(String variableName, int[][] matrix)
+			throws RWorkspaceException {
+		int ncol = 0;
+		if (matrix.length == 0) {
+			ncol = 0;
+		} else {
+			ncol = matrix[0].length;
+		}
+		int nrow = matrix.length;
+		int[] vector = VectorizeArray.vectorizeByInner(matrix);
+		if (!filecommunication) {
+			try {
+				connection.assign(variableName, vector);
+			} catch (REngineException e) {
+				throw new RWorkspaceException(e);
+			}
+			try {
+				connection .voidEval(variableName
+						+ "<- matrix(" + variableName + ", nrow=" + nrow + ", ncol=" + ncol + ", byrow=T)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			} catch (RserveException e) {
+				throw new RWorkspaceException(e);
+			}
+		} else {
+			comm.assign(variableName, vector, nrow, ncol);
+		}
+		Log.finest("MATRIX_ADDED_TO_WORKSPACE" + new Object[] { nrow, ncol, variableName }); //$NON-NLS-1$
+	}
+
+	/**
+	 * Adds the vector to workspace.
+	 *
+	 * @param variableName the variable name
+	 * @param vector the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void addVectorToWorkspace(String variableName, double[] vector)
+			throws RWorkspaceException {
+		if (filecommunication) {
+			comm.assign(variableName, vector);
+		} else {
+			try {
+				connection.assign(variableName, vector);
+			} catch (REngineException e) {
+				throw new RWorkspaceException(e);
+			}
+		}
+
+		Log.finest("DOUBLE_VECTOR_ADDED_TO_WORKSPACE" + new Object[] { vector.length, variableName }); //$NON-NLS-1$
+	}
+
+	/**
+	 * Add a vector into the workspace and link it to a name.
+	 *
+	 * @param variableName the variable name
+	 * @param vector the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void addVectorToWorkspace(String variableName, DoubleArrayList vector)
+			throws RWorkspaceException {
+
+		vector.trimToSize();
+		double[] vald = vector.elements();
+		if (filecommunication) {
+			comm.assign(variableName, vald);
+		} else {
+			try {
+				connection.assign(variableName, vald);
+			} catch (REngineException e) {
+				throw new RWorkspaceException(e);
+			}
+		}
+		Log.finest("DOUBLE_VECTOR_ADDED_TO_WORKSPACE" + new Object[] { vald.length, variableName }); //$NON-NLS-1$
+	}
+
+	/**
+	 * Adds the vector to workspace.
+	 *
+	 * @param variableName the variable name
+	 * @param vector the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void addVectorToWorkspace(String variableName, int[] vector)
+			throws RWorkspaceException {
+		//checkForDuplicateVariable(variableName);
+		if (filecommunication) {
+			comm.assign(variableName, vector);
+		} else {
+			try {
+				connection.assign(variableName, vector);
+			} catch (REngineException e) {
+				throw new RWorkspaceException(e);
+			}
+		}
+
+		Log.finest("INT_VECTOR_ADDED_TO_WORKSPACE" + new Object[] { vector.length, variableName }); //$NON-NLS-1$
+	}
+
+	/**
+	 * Adds the vector to workspace.
+	 *
+	 * @param variableName the variable name
+	 * @param vector the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void addVectorToWorkspace(String variableName, IntArrayList vector)
+			throws RWorkspaceException {
+		vector.trimToSize();
+		int[] vald = vector.elements();
+		if (filecommunication) {
+			comm.assign(variableName, vald);
+		} else {
+			try {
+				connection.assign(variableName, vald);
+			} catch (REngineException e) {
+				throw new RWorkspaceException(e);
+			}
+		}
+
+		Log.finest("INT_VECTOR_ADDED_TO_WORKSPACE" + new Object[] { vald.length, variableName }); //$NON-NLS-1$
+	}
+
+	// --------------------------------------
+
+	/**
+	 * Adds the vector to workspace.
+	 *
+	 * @param variableName the variable name
+	 * @param vector the vector
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void addVectorToWorkspace(String variableName, String[] vector)
+			throws RWorkspaceException {
+
+		try {
+			connection.assign(variableName, vector);
+		} catch (REngineException e) {
+			throw new RWorkspaceException(e);
+		}
+
+		Log.finest("CHAR_VECTOR_ADDED_TO_WORKSPACE" + new Object[] { vector.length, variableName }); //$NON-NLS-1$
+	}
+
+	/**
+	 * Assign col names to matrix.
+	 *
+	 * @param matrix the matrix
+	 * @param colNames the col names
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void assignColNamesToMatrix(String matrix, String colNames)
+			throws RWorkspaceException {
+		voidEval("colnames(" + matrix + ") <- " + colNames); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	/**
+	 * Assign row names to matrix.
+	 *
+	 * @param matrix the matrix
+	 * @param rowNames the row names
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void assignRowNamesToMatrix(String matrix, String rowNames)
+			throws RWorkspaceException {
+		voidEval("rownames(" + matrix + ") <- " + rowNames); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	/**
+	 * Builds the string args.
+	 *
+	 * @param arguments the arguments
+	 * @return the string[]
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	private String[] buildStringArgs(QuantitativeDataStructure[] arguments) throws RWorkspaceException {
+		String[] arguments_as_string = new String[arguments.length];
+		for (int i = 0; i < arguments_as_string.length; i++) {
+			if (arguments[i] == null) { // null may be used for specif ying
+				// "NULL" R object.
+				arguments_as_string[i] = "NULL"; //$NON-NLS-1$
+			} else {
+				if (!containsVariable(arguments[i].getSymbol())) {
+					throw new RWorkspaceException(Messages.REQUESTED_OBJECT
+							+ arguments[i].getSymbol()
+							+ Messages.NOT_FOUND_IN_R); 
+				}
+				arguments_as_string[i] = arguments[i].getSymbol();
+			}
+		}
+		return arguments_as_string;
+	}
+
+	/**
+	 * Call a function, with an array of {@link QuantitativeDataStructure}.
+	 * 
+	 * The <code>QuantitativeDataStructure</code> array is turned into a list of
+	 * non-named parameters, and {@link #callFunction(String, String[])} is
+	 * called.
+	 * 
+	 * If one of the <code>QuantitativeDataStructure</code> is <code>null</code>
+	 * , then the string "NULL" is used (= R null).
+	 *
+	 * @param functionName the function name
+	 * @param arguments of the function, as non-named parameters.
+	 * @return a REXP object
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public REXP callFunction(String functionName, QuantitativeDataStructure[] arguments) throws RWorkspaceException {
+		String[] arguments_as_string = buildStringArgs(arguments);
+		return callFunction(functionName, arguments_as_string);
+	}
+
+	/**
+	 * Call a function, with an array of {@link QuantitativeDataStructure}.
+	 * 
+	 * The <code>QuantitativeDataStructure</code> array is turned into a list of
+	 * non-named parameters, and {@link #callFunction(String, String[])} is
+	 * called.
+	 * 
+	 * If one of the <code>QuantitativeDataStructure</code> is <code>null</code>
+	 * , then the string "NULL" is used (= R null).
+	 *
+	 * @param functionName the function name
+	 * @param arguments of the function, as non-named parameters.
+	 * @param symbol the symbol
+	 * @return a REXP object
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public REXP callFunction(String functionName, QuantitativeDataStructure[] arguments, String symbol) throws RWorkspaceException {
+		String[] arguments_as_string = buildStringArgs(arguments);
+		return callFunctionAndAffect(functionName, arguments_as_string, symbol);
+	}
+
+	/**
+	 * See {@link #callFunction(String, String[])}.
+	 *
+	 * @param functionName the function name
+	 * @param argument the argument
+	 * @return the rEXP
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public REXP callFunction(String functionName, String argument)
+			throws RWorkspaceException {
+		return callFunction(functionName, new String[] { argument });
+	}
+
+	/**
+	 * Call a function, with a list of non-named parameters, and return the
+	 * result as a <code>REXP</code> object.
+	 *
+	 * @param functionName the function name
+	 * @param arguments of the function, as non-named parameters.
+	 * @return a REXP object
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public REXP callFunction(String functionName, String[] arguments)
+			throws RWorkspaceException {
+		//return eval(makeFunctionCall(functionName, arguments));
+		return callFunctionAndAffect(functionName, arguments, "txmresult"); //$NON-NLS-1$
+	}
+
+	/**
+	 * Same as {@link #callFunction(String, String[])}, but affect the result to
+	 * a R name in the R workspace.
+	 *
+	 * @param functionName the function name
+	 * @param arguments the arguments
+	 * @param symbol the name to which the result of the function will be affected.
+	 * @return the rEXP
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public REXP callFunctionAndAffect(String functionName, String[] arguments, String symbol) throws RWorkspaceException {
+		if (symbol.length() == 0)//symbol must be well formed
+			symbol = "txmresult"; //$NON-NLS-1$
+		StringBuffer sb = new StringBuffer();
+		sb.append(symbol);
+		sb.append(RConstant.AFFECTATION);
+		sb.append(makeFunctionCall(functionName, arguments));
+		return eval(sb.toString());
+	}
+
+	/**
+	 * Check for duplicate variable.
+	 *
+	 * @param variableName the variable name
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void checkForDuplicateVariable(String variableName)
+			throws RWorkspaceException {
+		if (containsVariable(variableName)) {
+			throw new RObjectAlreadyExist(
+					"Duplicate variable name: " + variableName + ". Existing variables: " + Arrays.toString(getExistingVariableName())); //$NON-NLS-1$ //$NON-NLS-2$
+		}
+	}
+
+
+	/**
+	 * Remove all variables from workspace.
+	 *
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void clearWorkspace() throws RWorkspaceException {
+		try {
+			connection.voidEval("rm(list=ls(), inherits=FALSE)"); //$NON-NLS-1$
+		} catch (RserveException e) {
+			throw new RWorkspaceException(e);
+		}
+		Log.finest("WORKSPACE_PURGED"); //$NON-NLS-1$
+	}
+
+	/**
+	 * connect to Rserve using the defaults address and port 127.0.0.1:6311
+	 *
+	 * @return true if success
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	private boolean connect() throws RWorkspaceException {
+		return connect("127.0.0.1", 6311); //$NON-NLS-1$
+	}
+
+	/**
+	 * Test if a variable exists in the R workspace. A variable exists in the R
+	 * workspace if the R function <code>exists</code> return true on that
+	 * variable name.
+	 *
+	 * @param variableName the variable supposed to exists in the R workspace.
+	 * @return <code>true</code> if the variable exist, <code>false</code>
+	 * otherwise.
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public boolean containsVariable(String variableName)
+			throws RWorkspaceException {
+		REXP res = null;
+		try {
+			res = connection.eval("exists(\"" + variableName + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (RserveException e) {
+			throw new RWorkspaceException(e);
+		}
+		if (res.isLogical() && ((REXPLogical) res).isTRUE()[0]) {
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Bar delegate call to {@link Rengine#eval(String)}.
+	 * 
+	 * It is up to the caller to check if everything goes well (testing if the
+	 * return value is not of type XT_NULL).
+	 *
+	 * @param exp the exp
+	 * @return the rEXP
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public synchronized REXP eval(String exp) throws RWorkspaceException {
+		REXP res = null;
+		try {
+			res = safeEval(exp);
+		} catch (RserveException e) {
+			RWorkspace.printLastSafeEvalExpr();
+			throw new RWorkspaceException(e);
+		} catch (REXPMismatchException e) {
+			throw new RException(exp + "; " + e.getMessage(), e); //$NON-NLS-1$
+		}
+		//Log.finest("EVALUATED_EXPRESSION" + exp ); //$NON-NLS-1$
+		return res;
+	}
+
+	/**
+	 * Eval to double.
+	 *
+	 * @param exp the exp
+	 * @return the double[]
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public double[] evalToDouble(String exp) throws RWorkspaceException {
+		double[] res = null;
+		try {
+			res = eval(exp).asDoubles();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+		return res;
+	}
+
+	// public REXP safeVoidEval(String s) throws RserveException, RException,
+	// REXPMismatchException {
+	// REXP r = connection.voidEval("try({" + s + "}, silent=TRUE)");
+	// if (r.inherits("try-error")) throw new RException(r.asString());
+	// return r;
+	// }
+
+	/**
+	 * Eval to double2 d.
+	 *
+	 * @param exp the exp
+	 * @return the double[][]
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public double[][] evalToDouble2D(String exp) throws RWorkspaceException {
+		double[][] res = null;
+		try {
+			res = eval(exp).asDoubleMatrix();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+		return res;
+	}
+
+	/*
+	 * Eval to int 2d.
+	 *
+	 * @param exp the exp
+	 * @return the double[][]
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public int[][] evalToInt2D(String exp) throws RWorkspaceException {
+		int[][] res = null;
+		try {
+			int[] dims = eval(Messages.MatrixImpl_2+exp+")").asIntegers(); //$NON-NLS-2$
+			int ncol = dims[1];
+			int nrow = dims[0];
+			int[] tmp = eval("c("+exp+")").asIntegers(); //$NON-NLS-1$ //$NON-NLS-2$
+
+			int c = 0;
+			res = new int[nrow][ncol];
+			for (int i = 0 ; i < ncol ; i++) {
+				for (int j = 0 ; j < nrow ; j++) {
+					res[j][i] = tmp[c++];
+				}
+			}
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+		return res;
+	}
+
+	/**
+	 * Eval to string.
+	 *
+	 * @param exp the exp
+	 * @return the string[]
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public String[] evalToString(String exp) throws RWorkspaceException {
+		String[] res = null;
+		try {
+			res = eval(exp).asStrings();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+		return res;
+	}
+
+	/**
+	 * Extract item from list by name.
+	 *
+	 * @param list the list
+	 * @param item_name the item_name
+	 * @return the rEXP
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public REXP extractItemFromListByName(REXP list, String item_name)
+			throws RWorkspaceException {
+		try {
+			return list.asList().at(item_name);
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(Messages.ERROR_EXTRACT_ITEM
+					+ e.getMessage()); 
+		}
+	}
+
+	/**
+	 * Extract item from list by name.
+	 *
+	 * @param list_symbol the list_symbol
+	 * @param item_name the item_name
+	 * @return the rEXP
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public REXP extractItemFromListByName(String list_symbol, String item_name)
+			throws RWorkspaceException {
+		return eval(list_symbol + RConstant.LIST_EXTRACTOR + item_name);
+	}
+
+	/**
+	 * Gets the connection.
+	 *
+	 * @return the connection
+	 */
+	public RConnection getConnection() {
+		return connection;
+	}
+
+	public StreamHog getErrorLogger() {
+		return errorLogger;
+	}
+
+	// --------------------------------------
+
+	/**
+	 * Gets the existing variable name.
+	 *
+	 * @return the existing variable name
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	private String[] getExistingVariableName() throws RWorkspaceException {
+		REXP res;
+		try {
+			res = connection.eval("ls()"); //$NON-NLS-1$
+		} catch (RserveException e) {
+			throw new RWorkspaceException(e);
+		}
+		try {
+			return res.asStrings();
+		} catch (REXPMismatchException e) {
+			throw new RWorkspaceException(e);
+		}
+	}
+
+	// --------------------------------------
+
+	public StreamHog getInputLogger() {
+		return inputLogger;
+	}
+
+	/**
+	 * Gets the last error line.
+	 *
+	 * @return the last error line
+	 */
+	public String getLastErrorLine() {
+		return this.errorLogger.lastline;
+	}
+
+	/**
+	 * Gets the last log line.
+	 *
+	 * @return the last log line
+	 */
+	public String getLastLogLine() {
+		return this.inputLogger.lastline;
+	}
+
+	/**
+	 * Initializes the R connection configuration (time out and proxy configuration, if needed). 
+	 * @param conf
+	 * @throws RserveException
+	 */
+	public void initializeRWorkspaceConnectionConfiguration(SystemProxyDetector conf) throws RserveException {
+		
+		// reduce time out
+		Log.warning("Setting R connection time out to 3 seconds.");
+		this.getConnection().eval("options(timeout = 3);"); //$NON-NLS-1$
+		
+		// configure the HTTP proxy
+		if (conf.isSystemProxyDetected()) {
+			String proxyUrl = conf.getHttpProxyUrl();
+			Log.warning("Setting R proxy configuration from system proxy configuration to: " + proxyUrl);
+			this.getConnection().eval("Sys.setenv(http_proxy=\"" + proxyUrl + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
+		}
+	}
+
+	/**
+	 * Checks if is logging.
+	 *
+	 * @return true, if is logging
+	 */
+	public boolean isLogging() {
+		// TODO Auto-generated method stub
+		return logging;
+	}
+
+	// --------------------------------------
+
+	/**
+	 * Make function call.
+	 *
+	 * @param functionName the function name
+	 * @param arguments the arguments
+	 * @return the string
+	 */
+	private String makeFunctionCall(String functionName, String[] arguments) {
+		StringBuffer sb = new StringBuffer();
+		sb.append(functionName);
+		sb.append(RConstant.OPEN_PAREN);
+		for (int i = 0; i < arguments.length; i++) {
+			sb.append(arguments[i]);
+			if ((i + 1) < arguments.length) {
+				sb.append(", "); //$NON-NLS-1$
+			}
+		}
+		sb.append(RConstant.CLOSE_PAREN);
+		return sb.toString();
+	}
+
+	@SuppressWarnings("rawtypes")
+	/**
+	 * Post configuration.
+	 *
+	 * @param rPackagesPath the r packages path
+	 * @return true, if successful
+	 */
+	public boolean postConfiguration(String rPackagesPath) {
+		// System.out.println("R post configuration");
+		try {
+			// more logs
+			connection.eval("try(options(max.print=5000))"); //$NON-NLS-1$
+
+			// set TXM R workspace directory
+			File RWorkspaceDirectory = new File(userdir, "R"); //$NON-NLS-1$
+			RWorkspaceDirectory.mkdir();
+			if (!RWorkspaceDirectory.exists()) {
+				System.out.println("TXM R workspace directory not found: "+RWorkspaceDirectory);
+			} else {
+				Log.warning("Setting TXM R workspace directory: "+RWorkspaceDirectory.getAbsolutePath());
+				connection.eval("setwd(\""+RWorkspaceDirectory.getAbsolutePath().replace("\\", "/")+"\")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			}
+
+			File RLibrariesWorkspaceDirectory = new File(userdir, "R/libraries");
+			RLibrariesWorkspaceDirectory.mkdir();
+			if (!RLibrariesWorkspaceDirectory.exists()) {
+				System.out.println("TXM R libraries workspace directory not found: "+RLibrariesWorkspaceDirectory);
+			} else {
+				Log.warning("Setting TXM R libraries workspace directory: "+RLibrariesWorkspaceDirectory.getAbsolutePath());
+				connection.eval(".libPaths(c(\""+RLibrariesWorkspaceDirectory.getAbsolutePath().replace("\\", "/")+"\",.libPaths()))");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			}
+
+			if (OSDetector.isFamilyWindows())	{
+				rPackagesPath = rPackagesPath.replace("\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+
+
+			// set proxy configuration using detected system proxy if exists
+			SystemProxyDetector conf = new SystemProxyDetector();
+			this.initializeRWorkspaceConnectionConfiguration(conf);
+
+			// load R libraries: this is now done by extensions/commands themself
+			try {
+				init(); // load libs
+			} catch (RWorkspaceException e) {
+				org.txm.utils.logger.Log.printStackTrace(e);
+				return false;
+			}
+
+			//connection.eval("try(.libPaths(\"" + rPackagesPath + "\"))"); //$NON-NLS-1$ //$NON-NLS-2$
+
+			return true;
+		} catch (RserveException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		return false;
+	}
+
+	/**
+	 * Start logger.
+	 *
+	 * @param streamHog the stream hog
+	 * @param streamHog2 the stream hog2
+	 * @return the r workspace
+	 */
+	public RWorkspace registerLogger(StreamHog streamHog, StreamHog streamHog2) {
+		this.errorLogger = streamHog;
+		this.inputLogger = streamHog2;
+		return null;
+	}
+
+	/**
+	 * Remove a variable from the workspace. The content is lost, and the name
+	 * refers to nothing.
+	 *
+	 * @param variableName the variable name
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void removeVariableFromWorkspace(String variableName)
+			throws RWorkspaceException {
+		try {
+			connection.voidEval("rm(" + variableName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+		} catch (RserveException e) {
+			throw new RWorkspaceException(e);
+		}
+		Log.finest("VARIABLE_REMOVED: " + new Object[] { variableName }); //$NON-NLS-1$
+	}
+
+	/**
+	 * Safe eval.
+	 *
+	 * @param expr the expr
+	 * @return the rEXP
+	 * @throws RserveException the rserve exception
+	 * @throws RException the r exception
+	 * @throws REXPMismatchException the rEXP mismatch exception
+	 */
+	public REXP safeEval(String expr) throws RserveException, RException,
+	REXPMismatchException {
+		if (logging && inputLogger != null ) inputLogger.printMessage(expr); //$NON-NLS-1$
+		lastSafeevalExpr = expr;
+		Log.finest("Reval: " + expr); //$NON-NLS-1$
+		REXP r = connection.eval("try({" + expr + "}, silent=TRUE)"); //$NON-NLS-1$ //$NON-NLS-2$
+		if (r !=null && r.inherits("try-error")) throw new RException(expr, r.asString()); //$NON-NLS-1$
+		return r;
+	}
+
+	/**
+	 * Sets the log.
+	 *
+	 * @param start the new log
+	 */
+	public void setLog(boolean start)
+	{
+		logging = start;
+		if (errorLogger != null)
+			this.errorLogger.setPrint(start);
+		if (inputLogger != null)
+			this.inputLogger.setPrint(start);
+	}
+
+	/**
+	 * Start logger.
+	 *
+	 * @param streamHog the stream hog
+	 * @param streamHog2 the stream hog2
+	 * @return the r workspace
+	 */
+	public RWorkspace stopLogger() {
+		this.errorLogger.stopLogging();
+		this.inputLogger.stopLogging();
+		return null;
+	}
+
+	/**
+	 * To txt.
+	 *
+	 * @param file the file
+	 * @param symbol the symbol
+	 * @throws StatException the stat exception
+	 */
+	public void toTxt(File file, String symbol) throws StatException {
+		eval("write.table(" + symbol + Messages.RWorkspace_4 + file.getAbsolutePath().replace("\\", "\\\\") + Messages.RWorkspace_5); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	}
+
+	/**
+	 * Bar delegate call to {@link Connection#voidEval(String)}.
+	 * 
+	 * It is up to the caller to check if everything goes well (testing if the
+	 * return value is not of type XT_NULL).
+	 *
+	 * @param exp the exp
+	 * @return the string
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public String userEval(String exp) throws RWorkspaceException {
+		if (exp.trim().length() == 0)
+			return ""; //$NON-NLS-1$
+		//if (loggin)
+		//System.out.println("R>"+exp); //$NON-NLS-1$
+
+		if (exp.endsWith(";")) //$NON-NLS-1$
+			exp = exp.substring(0, exp.length()-1);
+
+		//		String trybegin = "try("; //$NON-NLS-1$
+		//		String tryend = ")"; //$NON-NLS-1$
+
+		String out = null;
+		try {
+			//out = connection.eval("paste(capture.output(print(" + trybegin + trybegin +"("+ exp+")" + tryend + tryend + ")),collapse=\"\\n\")").asString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			//String cmd = "paste(capture.output(print(" + trybegin + "("+ exp+")" + tryend + ")),collapse=\"\\n\")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			Log.info("R eval: "+exp);
+			REXP ret = connection.eval(exp); 
+			//REXP ret = connection.eval(exp);
+
+			if (ret instanceof org.rosuda.REngine.REXPString) {
+				if (ret.isVector()) {
+					out =  "result: "+StringUtils.join(ret.asStrings(), ", ");
+				} else {
+					out =  "result: "+ret.asString();
+				} 
+			} else if (ret instanceof org.rosuda.REngine.REXPDouble) {
+				if (ret.isVector()) {
+					out = "result: "+ret.asDouble();
+				} else {
+					out =  "result: "+Arrays.toString(ret.asDoubles());
+				}
+			}  else if (ret instanceof org.rosuda.REngine.REXPInteger) {
+				if (ret.isVector()) {
+					out = "result: "+ret.asInteger();
+				} else {
+					out =  "result: "+Arrays.toString(ret.asIntegers());
+				}
+			} else if (ret instanceof org.rosuda.REngine.REXPNull) {
+				out =  "NULL";
+			} else {
+				out =  "result: "+ret;
+			}
+			
+		} catch (REXPMismatchException e) {
+			System.out.println("REXPMismatchException: "+e);
+			Log.printStackTrace(e);
+		} catch (RserveException e) {
+			System.out.println(Messages.RWorkspace_1 + e.getMessage()+" : "+exp);  //$NON-NLS-1$
+			Log.printStackTrace(e);
+		}
+
+		Log.finest("EVALUATED_EXPRESSION: " + exp ); //$NON-NLS-1$
+		return out;
+	}
+
+	/**
+	 * Bar delegate call to {@link Connection#voidEval(String)}.
+	 * 
+	 * It is up to the caller to check if everything goes well (testing if the
+	 * return value is not of type XT_NULL).
+	 *
+	 * @param exp the exp
+	 * @throws RWorkspaceException the r workspace exception
+	 */
+	public void voidEval(String exp) throws RWorkspaceException {
+
+		if (exp.endsWith(";")) //$NON-NLS-1$
+			exp = exp.substring(0, exp.length()-1);
+
+		//		String trybegin = "try("; //$NON-NLS-1$
+		//		String tryend = ")"; //$NON-NLS-1$
+
+		try {
+			safeEval(exp);
+		} catch (RserveException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (REXPMismatchException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+
+		Log.finest("EVALUATED_EXPRESSION: " + exp ); //$NON-NLS-1$
+	}
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/engine/r/RWorkspace.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/org/txm/stat/ConnectToRserve.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.r/src/org/txm/stat/org/txm/stat/ConnectToRserve.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.r/src/org/txm/stat/data/package.html
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/data/package.html	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/data/package.html	(revision 219)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Definition of quantitative data structures for representing corpus.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.r/src/org/txm/stat/data/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/data/Vector.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/data/Vector.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/data/Vector.java	(revision 219)
@@ -0,0 +1,155 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.data;
+
+import java.util.List;
+
+import org.txm.stat.StatException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The interface Vector.
+ * 
+ * @author sloiseau
+ */
+public interface Vector extends QuantitativeDataStructure {
+
+	/**
+	 * Get the sub-vector given index.
+	 * 
+	 * @param index
+	 *            0-based index.
+	 * 
+	 * @return a new vector, copy to the selected values (modif ication to the
+	 *         vector returned does not modif y the vector).
+	 * 
+	 * @throws StatException
+	 *             if anything goes wrong.
+	 */
+	public Vector get(int[] index) throws StatException;
+
+	/**
+	 * Convert the vector to a java array of <code>int</code>, if possible.
+	 * 
+	 * @return a java array of <code>int</code>.
+	 * 
+	 * @throws StatException
+	 *             if anything goes wrong, ni particular if this Vector cannot
+	 *             be converted into <code>int</code>.
+	 */
+	public int[] asIntArray() throws StatException;
+
+	/**
+	 * Convert the vector to a java array of <code>double</code>, if possible.
+	 * 
+	 * @return a java array of <code>double</code>.
+	 * 
+	 * @throws StatException
+	 *             if anything goes wrong, ni particular if this Vector cannot
+	 *             be converted into <code>double</code>.
+	 */
+	public double[] asDoubleArray() throws StatException;
+
+	/**
+	 * Convert the vector to a java array of <code>String</code>, if possible.
+	 * 
+	 * @return a java array of <code>String</code>.
+	 * 
+	 * @throws StatException
+	 *             if anything goes wrong, ni particular if this Vector cannot
+	 *             be converted into <code>String</code>.
+	 */
+	public String[] asStringsArray() throws StatException;
+
+	/**
+	 * Get the length of the vector.
+	 * 
+	 * @return the length.
+	 * 
+	 * @throws StatException
+	 *             if anything goes wrong.
+	 */
+	public int getLength() throws StatException;
+
+	/**
+	 * Removes the.
+	 *
+	 * @param col the col
+	 * @return true, if successful
+	 */
+	public boolean remove(int col);
+
+	/**
+	 * Sets the string.
+	 *
+	 * @param i the i
+	 * @param value the value
+	 */
+	public void setString(int i, String value);
+
+	/**
+	 * Sets the int.
+	 *
+	 * @param i the i
+	 * @param value the value
+	 */
+	public void setInt(int i, int value);
+
+	/**
+	 * Sets the double.
+	 *
+	 * @param i the i
+	 * @param value the value
+	 */
+	public void setDouble(int i, double value);
+
+	/**
+	 * Sort.
+	 *
+	 * @param reverse the reverse
+	 */
+	public void sort(Boolean reverse);
+
+	/**
+	 * Sets the order.
+	 *
+	 * @param neworder the neworder
+	 * @param reverse the reverse
+	 */
+	public void setOrder(List<Integer> neworder, Boolean reverse);
+
+	/**
+	 * Cut.
+	 *
+	 * @param nlines the nlines
+	 */
+	public void cut(int nlines);
+
+	// public String get(int i);
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/data/Vector.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/data/Matrix.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/data/Matrix.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/data/Matrix.java	(revision 219)
@@ -0,0 +1,129 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.data;
+
+import org.txm.stat.StatException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Interface Matrix, root of all other matrix-like structure.
+ * 
+ * @author sloiseau
+ */
+public interface Matrix extends QuantitativeDataStructure {
+
+	/**
+	 * Get the value at the specif ied cell.
+	 *
+	 * @param row 0-based row index
+	 * @param col 0-based column index
+	 * @return the value as a <code>double</code>
+	 * @throws StatException the stat exception
+	 */
+	public double get(int row, int col) throws StatException;
+
+	/**
+	 * The number of rows in the contingency table.
+	 * 
+	 * @return the number of raw
+	 */
+	public abstract int getNRows();
+
+	/**
+	 * Exchange 2 columns in the lexical table
+	 * @param c1 1..N+1
+	 * @param c2 1..N+1
+	 */
+	public abstract void exchangeColumns(int c1, int c2);
+	
+	/**
+	 * The number of columns in the contingency table.
+	 * 
+	 * @return the number of columns
+	 */
+	public abstract int getNColumns();
+
+	/**
+	 * Get the row names or null if no row names.
+	 * 
+	 * Row names are available if the
+	 *
+	 * @return the row names
+	 * {@link #Matrix(DoubleMatrix2D, String[], String[], Header)} constructor
+	 * has been used for this object.
+	 */
+	public abstract Vector getRowNames();
+
+	/**
+	 * Get the col names or null if no col names.
+	 * 
+	 * Col names are available if the
+	 *
+	 * @return the col names
+	 * {@link #Matrix(DoubleMatrix2D, String[], String[], Header)} constructor
+	 * has been used for this object.
+	 */
+	public abstract Vector getColNames();
+
+	/**
+	 * Gets a row vector as a Vector object.
+	 *
+	 * @param index 0-based row index.
+	 * @return the row
+	 * @throws StatException the stat exception
+	 */
+	public abstract Vector getRow(int index) throws StatException;
+
+	/**
+	 * Gets a column vector as a Vector object.
+	 *
+	 * @param index 0-based index column index.
+	 * @return the row
+	 * @throws StatException the stat exception
+	 */
+	public abstract Vector getCol(int index) throws StatException;
+
+	/**
+	 * Gets a column vector as a Vector object.
+	 *
+	 * @param column the column name
+	 * @return the column vector
+	 * @throws StatException the stat exception
+	 */
+	public abstract Vector getCol(String column) throws StatException;
+
+	/**
+	 * Gets a row vector as a Vector object.
+	 *
+	 * @param row the row name
+	 * @return the row vector
+	 * @throws StatException the stat exception
+	 */
+	public abstract Vector getRow(String row) throws StatException;
+
+}
\ No newline at end of file

Property changes on: tmp/org.txm.r/src/org/txm/stat/data/Matrix.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/data/ContingencyTable.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/data/ContingencyTable.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/data/ContingencyTable.java	(revision 219)
@@ -0,0 +1,91 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.data;
+
+import org.txm.stat.StatException;
+import org.txm.stat.engine.r.RWorkspaceException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Interface ContingencyTable.
+ * 
+ * @author sloiseau
+ */
+public interface ContingencyTable extends Matrix {
+
+	/**
+	 * Gets the row margin.
+	 * 
+	 * @return the row margin
+	 * 
+	 * @throws RWorkspaceException
+	 *             the r workspace exception
+	 */
+	public Vector getRowMarginsVector() throws StatException;
+
+	/**
+	 * Gets the col margin.
+	 * 
+	 * @return the col margin
+	 * 
+	 * @throws RWorkspaceException
+	 *             the r workspace exception
+	 */
+	public Vector getColMarginsVector() throws StatException;
+	
+	/**
+	 * Gets the col margin.
+	 * 
+	 * @return the col margin
+	 * 
+	 * @throws RWorkspaceException
+	 *             the r workspace exception
+	 */
+	public int[] getColMargins() throws Exception;
+	
+	/**
+	 * Gets the col margin.
+	 * 
+	 * @return the col margin
+	 * 
+	 * @throws RWorkspaceException
+	 *             the r workspace exception
+	 */
+	public int[] getRowMargins() throws Exception;
+
+	/**
+	 * Gets the total.
+	 * 
+	 * @return the total
+	 * 
+	 * @throws RWorkspaceException
+	 *             the r workspace exception
+	 */
+	public int getTotal() throws RWorkspaceException;
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/data/ContingencyTable.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/data/QuantitativeDataStructure.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/data/QuantitativeDataStructure.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/data/QuantitativeDataStructure.java	(revision 219)
@@ -0,0 +1,46 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.data;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The root of all other data structures.
+ * 
+ * @author sloiseau
+ */
+public interface QuantitativeDataStructure {
+
+	/**
+	 * The symbol is a the name of the data structure in a wrapped statistical
+	 * engine.
+	 * 
+	 * @return the symbol of this data structure.
+	 */
+	public String getSymbol();
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/data/QuantitativeDataStructure.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/StatException.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/StatException.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/StatException.java	(revision 219)
@@ -0,0 +1,82 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat;
+
+// TODO: Auto-generated Javadoc
+/**
+ * General exception in statistical computing, the super class of all exceptions
+ * related to statistical computing.
+ * 
+ * @author sloiseau
+ * 
+ */
+public class StatException extends Exception {
+	
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 7220819361950262761L;
+
+	/**
+	 * Instantiates a new stat exception.
+	 */
+	public StatException() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new stat exception.
+	 *
+	 * @param message the message
+	 * @param cause the cause
+	 */
+	public StatException(String message, Throwable cause) {
+		super(message, cause);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new stat exception.
+	 *
+	 * @param message the message
+	 */
+	public StatException(String message) {
+		super(message);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new stat exception.
+	 *
+	 * @param cause the cause
+	 */
+	public StatException(Throwable cause) {
+		super(cause);
+		// TODO Auto-generated constructor stub
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/StatException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/package.html
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/package.html	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/package.html	(revision 219)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Root package of all statistical and numeric computing functions of the toolbox.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.r/src/org/txm/stat/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/utils/CheckArray.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/utils/CheckArray.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/utils/CheckArray.java	(revision 219)
@@ -0,0 +1,98 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.utils;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Various utility methods for checking consistency of matrix as java array of
+ * arrays.
+ * 
+ * @author sloiseau
+ * 
+ */
+public final class CheckArray {
+
+	/**
+	 * Check if an array is not null (or 0-length), does not include null inner
+	 * array (or 0 length), and if all inner arrays have the same length.
+	 *
+	 * @param array the array
+	 * @return <code>true</code> if the condition are satisfied,
+	 * <code>false</code> otherwise.
+	 */
+	public final static boolean checkMatrixRepresentation(int[][] array) {
+		// same code as in #checkMatrixRepresentation(double[][])
+		if (array == null)
+			return false;
+		int length = array.length;
+		if (length < 1)
+			return false;
+		if (array[0] == null)
+			return false;
+		int firstElementLength = array[0].length;
+		if (firstElementLength == 0)
+			return false;
+		for (int i = 0; i < array.length; i++) {
+			if (array[i] == null)
+				return false;
+			if (array[i].length != firstElementLength)
+				return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Check if an array is not null (or 0-length), does not include null inner
+	 * array (or 0 length), and if all inner arrays have the same length.
+	 *
+	 * @param array the array
+	 * @return <code>true</code> if the condition are satisfied,
+	 * <code>false</code> otherwise.
+	 */
+	public final static boolean checkMatrixRepresentation(double[][] array) {
+		// same code as in #checkMatrixRepresentation(int[][])
+		if (array == null)
+			return false;
+		int length = array.length;
+		if (length < 1)
+			return false;
+		if (array[0] == null)
+			return false;
+		int firstElementLength = array[0].length;
+		if (firstElementLength == 0)
+			return false;
+		for (int i = 0; i < array.length; i++) {
+			if (array[i] == null)
+				return false;
+			if (array[i].length != firstElementLength)
+				return false;
+		}
+		return true;
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/utils/CheckArray.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/utils/package.html
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/utils/package.html	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/utils/package.html	(revision 219)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Utility functions for dealing with array (vectorizing, indexing, checking consistency...).</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.r/src/org/txm/stat/utils/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/utils/ArrayIndex.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/utils/ArrayIndex.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/utils/ArrayIndex.java	(revision 219)
@@ -0,0 +1,101 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.txm.Messages;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Utilities for managing index of vector.
+ * 
+ * @author sloiseau
+ * 
+ */
+public final class ArrayIndex {
+
+	/**
+	 * Convert an array of zero-based index to an array of one-base index, that
+	 * is, add <code>1</code> to all elements.
+	 * 
+	 * This method check every index (see exception thrown).
+	 *
+	 * @param zero_based the zero based index.
+	 * @param length the number of elements that can be indexed.
+	 * @return the one base index.
+	 */
+	public static final int[] zeroToOneBasedIndex(int[] zero_based, int length) {
+		if (zero_based == null || zero_based.length == 0) {
+			throw new IllegalArgumentException(Messages.ArrayIndex_0);
+		}
+		int[] one_based = new int[zero_based.length];
+		for (int i = 0; i < zero_based.length; i++) {
+			if (zero_based[i] < 0 || zero_based[i] >= length) {
+				throw new IllegalArgumentException(Messages.ArrayIndex_1);
+			}
+			one_based[i] = zero_based[i] + 1;
+		}
+		return one_based;
+	}
+
+	/**
+	 * Zero to one based index.
+	 *
+	 * @param zero_based the zero_based
+	 * @return the int
+	 */
+	public static final int zeroToOneBasedIndex(int zero_based) {
+		return zero_based + 1;
+	}
+
+	/**
+	 * Get the index (0-based) of the element of subvector into vector. Return
+	 * <code>-1</code> when no element in vector correspond to the element in
+	 * subvector.
+	 *
+	 * @param vector the vector
+	 * @param subvector the subvector
+	 * @return the index
+	 */
+	public static int[] getIndex(String[] vector, String[] subvector) {
+		int[] result = new int[subvector.length];
+		Map<String, Integer> index = new HashMap<String, Integer>();
+		for (int i = 0; i < subvector.length; i++) {
+			index.put(subvector[i], i);
+			result[i] = -1;
+		}
+		for (int i = 0; i < vector.length; i++) {
+			if (index.containsKey(vector[i])) {
+				result[index.get(vector[i])] = i;
+			}
+		}
+		return result;
+	}
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/utils/ArrayIndex.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/utils/ArrayEquals.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/utils/ArrayEquals.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/utils/ArrayEquals.java	(revision 219)
@@ -0,0 +1,66 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.utils;
+
+import java.util.Arrays;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Utility methods for testing for equality of arrays.
+ * 
+ * @author sloiseau
+ * 
+ */
+public final class ArrayEquals {
+
+	/**
+	 * Test for equality of both array. For consistency with Arrays.equals
+	 * contract, the two arrays are equals if both are <code>null</code>.
+	 *
+	 * @param array1 the array1
+	 * @param array2 the array2
+	 * @return <code>true</code> if (1) both arrays are <code>null</code> or if
+	 * (2) both arrays have the same length and contain pair of arrays
+	 * equals to each other according to
+	 * {@link Arrays#equals(int[], int[])}.
+	 */
+	public static final boolean deepEquals(int[][] array1, int[][] array2) {
+		if (array1 == null && array2 == null)
+			return true;
+		if (array1 == null || array2 == null)
+			return false;
+		if (array1.length != array2.length)
+			return false;
+		for (int i = 0; i < array2.length; i++) {
+			if (!Arrays.equals(array1[i], array2[i]))
+				return false;
+		}
+		return true;
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/utils/ArrayEquals.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/utils/VectorizeArray.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/utils/VectorizeArray.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/utils/VectorizeArray.java	(revision 219)
@@ -0,0 +1,185 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.utils;
+
+import org.txm.Messages;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Static methods for dealing vectorization of Arrays.
+ * 
+ * @author sloiseau
+ * 
+ */
+public final class VectorizeArray {
+
+	/**
+	 * Convert a <code>double * double</code> array in a <code>double</code>
+	 * array. Each inner array of the argument is added one after the other into
+	 * the result array.
+	 * 
+	 * <pre>
+	 * [
+	 * [1, 2, 3],
+	 * [4, 5, 6]
+	 * ]
+	 * </pre>
+	 * 
+	 * result in :
+	 * 
+	 * <pre>
+	 * [1, 2, 3, 4, 5, 6]
+	 * </pre>
+	 * 
+	 * that is, "row first".
+	 *
+	 * @param matrix a <code>double * double</code> array where all inner arrays
+	 * have the same length.
+	 * @return an array of <code>double</code> produced by vectorization of the
+	 * matrix.
+	 */
+	public final static double[] vectorizeByInner(double[][] matrix) {
+		if (matrix == null || matrix.length == 0) {
+			throw new IllegalArgumentException(Messages.VectorizeArray_0);
+		}
+		int inner_length = matrix[0].length;
+		if (inner_length < 1) {
+			throw new IllegalArgumentException(Messages.VectorizeArray_1);
+		}
+		double[] vector = new double[matrix.length * matrix[0].length];
+		for (int i = 0; i < matrix.length; i++) {
+			if (matrix[i] == null) {
+				throw new IllegalArgumentException(Messages.VectorizeArray_10);
+			}
+			if (inner_length != matrix[i].length) {
+				throw new IllegalArgumentException(Messages.VectorizeArray_3);
+			}
+			System.arraycopy(matrix[i], 0, vector, i * inner_length,
+					inner_length);
+		}
+		return vector;
+	}
+
+	/**
+	 * Convert a <code>int * int</code> array in a <code>double</code> array.
+	 * Each inner array of the argument is added one after the other into the
+	 * result array.
+	 * 
+	 * <pre>
+	 * [
+	 * [1, 2, 3],
+	 * [4, 5, 6]
+	 * ]
+	 * </pre>
+	 * 
+	 * result in :
+	 * 
+	 * <pre>
+	 * [1, 2, 3, 4, 5, 6]
+	 * </pre>
+	 * 
+	 * that is, "row first".
+	 *
+	 * @param matrix a <code>int * int</code> array where all inner arrays have the
+	 * same length.
+	 * @return an array of <code>int</code> produced by vectorization of the
+	 * matrix.
+	 */
+	public final static int[] vectorizeByInner(int[][] matrix) {
+		if (matrix == null || matrix.length == 0) {
+			throw new IllegalArgumentException(Messages.VectorizeArray_4);
+		}
+		int inner_length = matrix[0].length;
+		if (inner_length < 1) {
+			throw new IllegalArgumentException(Messages.VectorizeArray_5);
+		}
+		int[] vector = new int[matrix.length * matrix[0].length];
+		for (int i = 0; i < matrix.length; i++) {
+			if (matrix[i] == null) {
+				throw new IllegalArgumentException(Messages.VectorizeArray_10);
+			}
+			if (inner_length != matrix[i].length) {
+				throw new IllegalArgumentException(Messages.VectorizeArray_7);
+			}
+			System.arraycopy(matrix[i], 0, vector, i * inner_length,
+					inner_length);
+		}
+		return vector;
+	}
+
+	/**
+	 * Convert a <code>double * double</code> array in a <code>double</code>
+	 * array. The elements of the input array are assembled in the output array
+	 * so that elements of same index in the outer array are consecutive. So :
+	 * 
+	 * <pre>
+	 * [
+	 * [1, 2, 3],
+	 * [4, 5, 6]
+	 * ]
+	 * </pre>
+	 * 
+	 * result in :
+	 * 
+	 * <pre>
+	 * [1, 4, 2, 5, 3, 6]
+	 * </pre>
+	 * 
+	 * that is, "column first".
+	 *
+	 * @param matrix a <code>double * double</code> array where all inner arrays
+	 * have the same length.
+	 * @return an array of <code>double</code> produced by vectorization of the
+	 * matrix.
+	 */
+	public final static double[] vectorizeByOuter(double[][] matrix) {
+		if (matrix == null || matrix.length == 0) {
+			throw new IllegalArgumentException(Messages.VectorizeArray_8);
+		}
+		int inner_length = matrix[0].length;
+		int outer_length = matrix.length;
+		if (inner_length < 1) {
+			throw new IllegalArgumentException(Messages.VectorizeArray_9);
+		}
+		double[] vector = new double[matrix.length * matrix[0].length];
+		for (int i = 0; i < matrix.length; i++) {
+			if (matrix[i] == null) {
+				throw new IllegalArgumentException(Messages.VectorizeArray_10);
+			}
+			if (inner_length != matrix[i].length) {
+				throw new IllegalArgumentException(Messages.VectorizeArray_11);
+			}
+			for (int j = 0; j < matrix[i].length; j++) {
+				vector[(j * outer_length) + i] = matrix[i][j];
+			}
+
+		}
+		return vector;
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/utils/VectorizeArray.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/src/org/txm/stat/utils/PrintArray.java
===================================================================
--- tmp/org.txm.r/src/org/txm/stat/utils/PrintArray.java	(revision 0)
+++ tmp/org.txm.r/src/org/txm/stat/utils/PrintArray.java	(revision 219)
@@ -0,0 +1,73 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.stat.utils;
+
+import java.util.Arrays;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Various utilities method for printing arrays.
+ * 
+ * @author sloiseau
+ * 
+ */
+public final class PrintArray {
+
+	/**
+	 * Double array.
+	 *
+	 * @param matrix the matrix
+	 * @return the string
+	 */
+	public final static String doubleArray(double[][] matrix) {
+		// DoubleMatrix2D m = new SparseDoubleMatrix2D(matrix);
+		// return m.toString();
+		StringBuffer sb = new StringBuffer();
+		for (int i = 0; i < matrix.length; i++) {
+			sb.append(Arrays.toString(matrix[i]));
+		}
+		return sb.toString();
+	}
+
+	/**
+	 * Int array.
+	 *
+	 * @param matrix the matrix
+	 * @return the string
+	 */
+	public final static String intArray(int[][] matrix) {
+		double[][] doublematrix = new double[matrix.length][matrix[0].length];
+		for (int i = 0; i < matrix.length; i++) {
+			for (int j = 0; j < doublematrix[i].length; j++) {
+				doublematrix[i][j] = matrix[i][j];
+			}
+		}
+		return doubleArray(doublematrix);
+	}
+
+}

Property changes on: tmp/org.txm.r/src/org/txm/stat/utils/PrintArray.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.r/colt-1.2.0.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.r/colt-1.2.0.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.r/build.properties
===================================================================
--- tmp/org.txm.r/build.properties	(revision 0)
+++ tmp/org.txm.r/build.properties	(revision 219)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               REngine.jar,\
+               RserveEngine.jar,\
+               colt-1.2.0.jar

Property changes on: tmp/org.txm.r/build.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

