【问题标题】:No output is coming not even error java with jri call to R没有输出甚至没有错误 java with jri call to R
【发布时间】:2014-03-20 14:59:40
【问题描述】:

下面是我的代码

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();

    }

}

上面的程序运行正常但没有输出

请帮忙,因为我是 Java 新手,有 r 集成....

【问题讨论】:

  • 我猜它正在等待R然后
  • 感谢您的回复。我认为您是对的,但是 r 已经在运行,那么为什么它没有被调用
  • eclipse 控制台显示 JRT...
  • 这怎么可能?没有显示其他内容?
  • 谢谢,但它没有显示在 Rengine re = new Rengine(new String[] {""}, false, null);行

标签: java eclipse r jri


【解决方案1】:

根据this link

REngine 的正确构造函数是

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

所以你的代码应该是

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

请注意,R 需要存在某些参数(例如 --save 或 --no-save 或等效项),因此传递空列表通常不起作用。

【讨论】:

猜你喜欢
  • 2016-03-15
  • 2017-09-25
  • 2020-11-25
  • 1970-01-01
  • 1970-01-01
  • 2015-04-17
  • 1970-01-01
  • 2011-02-17
  • 2023-03-19
相关资源
最近更新 更多