0

Below is my code

package org.quad.test;

import org.rosuda.JRI.Rengine;

public class JRT {

    public static void main(String[] args) {
        System.out.println("Cannot load R");
        // new R-engine
        Rengine re = new Rengine(new String[] {}, false, null);
        if (!re.waitForR()) {
            System.out.println("Cannot load R");
            return;
        } else {
            System.out.println(" load R");
        }

        // print a random number from uniform distribution
        System.out.println(re.eval("runif(1)").asDouble());
        System.out.println("Cannot load R");
        // done...
        re.end();

    }

}

Above program runs fine but no output

please help as i am new to java with r integration....

smali
  • 4,687
  • 7
  • 38
  • 60

1 Answers1

0

According to this link

The correct constructor for an REngine is

public Rengine(String[] args,
               boolean runMainLoop,
               RMainLoopCallbacks initialCallbacks)

so you code should be

Rengine re = new Rengine(args, false, null);

Please note that R requires the presence of certain arguments (e.g. --save or --no-save or equivalents), so passing an empty list usually doesn't work.

Scary Wombat
  • 44,617
  • 6
  • 35
  • 64
  • I changed and run it as Rengine re = new Rengine (new String [] {"--vanilla"}, false, null); ,Still same no output and program getting terminated – smali Mar 20 '14 at 07:12
  • Finally solved if using eclipse then this link works http://www.studytrails.com/RJava-Eclipse-Plugin/ if not using eclipse this link works http://stackoverflow.com/questions/19100875/java-r-interface-jri-setup – smali Mar 20 '14 at 08:17