Java 中的 Rsolnp 使用 Renjin
Rsolnp in Java using Renjin
我正在尝试 运行 使用 Java 程序解决问题。为了测试这是否有效,我正在尝试 运行 benchmarkids()
函数。但是我无法解决对包的引用。我已经在 http://packages.renjin.org/package/org.renjin.cran/Rsolnp/ 检查了 Rsolnp 包,据我所知,它可以在 renjin 中加载。
我已经添加了 Maven 所需的包:
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>Rsolnp</artifactId>
<version>1.16-b28</version>
</dependency>
我已经尝试将包直接添加到我的项目中(我使用的是 Eclipse Neon),仍然没有成功。
我遇到的错误:
org.renjin.eval.EvalException: Could not load package rsolnp; tried org.renjin.bioconductor:rsolnp, org.renjin.cran:rsolnp
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:160)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:115)
at org.renjin.primitives.packaging.Packages.library(Packages.java:41)
at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:73)
at org.renjin.primitives.R$primitive$library.apply(R$primitive$library.java:34)
at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:45)
at org.renjin.eval.Context.evaluateCall(Context.java:302)
at org.renjin.eval.Context.evaluate(Context.java:222)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:38)
at org.renjin.eval.Context.evaluateCall(Context.java:302)
at org.renjin.eval.Context.evaluate(Context.java:222)
at org.renjin.eval.Context.evaluate(Context.java:163)
at org.renjin.sexp.Closure.doApply(Closure.java:83)
at org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:73)
at org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:58)
at org.renjin.sexp.Closure.apply(Closure.java:78)
at org.renjin.eval.Context.evaluateCall(Context.java:302)
at org.renjin.eval.Context.evaluate(Context.java:222)
at org.renjin.eval.Context.evaluateExpressionVector(Context.java:285)
at org.renjin.eval.Context.evaluate(Context.java:220)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:168)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:127)
at test.java.RsolnpTest.testRsolnp(RsolnpTest.java:55)
最后,我要调用的代码:
import javax.script.*;
import org.renjin.script.*;
// some other tests to see if 10 * 2 in R works.
public void testRsolnp()
{
RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
ScriptEngine engine = factory.getScriptEngine();
try
{
engine.eval("library(rsolnp); benchmarkids();");
}
catch (ScriptException e)
{
e.printStackTrace();
}
// testing code.
}
R 中的包名称区分大小写。尝试:
engine.eval("library(Rsolnp); benchmarkids();");
我正在尝试 运行 使用 Java 程序解决问题。为了测试这是否有效,我正在尝试 运行 benchmarkids()
函数。但是我无法解决对包的引用。我已经在 http://packages.renjin.org/package/org.renjin.cran/Rsolnp/ 检查了 Rsolnp 包,据我所知,它可以在 renjin 中加载。
我已经添加了 Maven 所需的包:
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>Rsolnp</artifactId>
<version>1.16-b28</version>
</dependency>
我已经尝试将包直接添加到我的项目中(我使用的是 Eclipse Neon),仍然没有成功。
我遇到的错误:
org.renjin.eval.EvalException: Could not load package rsolnp; tried org.renjin.bioconductor:rsolnp, org.renjin.cran:rsolnp
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:160)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:115)
at org.renjin.primitives.packaging.Packages.library(Packages.java:41)
at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:73)
at org.renjin.primitives.R$primitive$library.apply(R$primitive$library.java:34)
at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:45)
at org.renjin.eval.Context.evaluateCall(Context.java:302)
at org.renjin.eval.Context.evaluate(Context.java:222)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:38)
at org.renjin.eval.Context.evaluateCall(Context.java:302)
at org.renjin.eval.Context.evaluate(Context.java:222)
at org.renjin.eval.Context.evaluate(Context.java:163)
at org.renjin.sexp.Closure.doApply(Closure.java:83)
at org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:73)
at org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:58)
at org.renjin.sexp.Closure.apply(Closure.java:78)
at org.renjin.eval.Context.evaluateCall(Context.java:302)
at org.renjin.eval.Context.evaluate(Context.java:222)
at org.renjin.eval.Context.evaluateExpressionVector(Context.java:285)
at org.renjin.eval.Context.evaluate(Context.java:220)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:168)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:127)
at test.java.RsolnpTest.testRsolnp(RsolnpTest.java:55)
最后,我要调用的代码:
import javax.script.*;
import org.renjin.script.*;
// some other tests to see if 10 * 2 in R works.
public void testRsolnp()
{
RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
ScriptEngine engine = factory.getScriptEngine();
try
{
engine.eval("library(rsolnp); benchmarkids();");
}
catch (ScriptException e)
{
e.printStackTrace();
}
// testing code.
}
R 中的包名称区分大小写。尝试:
engine.eval("library(Rsolnp); benchmarkids();");