执行简单的 ggplot2 脚本时出现错误。我认为从 Renjin 3.5 Beta 开始就支持 ggplot2 或者我做错了什么。我正在使用 ClasspathPackageLoader 并将 ggplot2 添加为 Gradle 依赖项。
repositories {
mavenCentral()
maven { url "https://nexus.bedatadriven.com/content/groups/public" }
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'org.renjin:renjin-script-engine:3.5-beta43'
compile 'org.renjin.cran:ggplot2:3.2.0-b8'
}
Java 代码相当简单:
RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
ScriptEngine engine = factory.getScriptEngine();
engine.eval("library(ggplot2)");
engine.eval("ggplot(mtcars, aes(mpg, wt)) + geom_point()");
engine.eval("ggsave('mtcars.png')");
完整的错误跟踪是:
> Task :Test.main() FAILED
Exception in thread "main" org.renjin.eval.EvalException: IOException while loading package org.renjin.cran:ggplot2: IOException while loading package org.renjin.cran:tibble: IOException while loading package org.renjin.cran:pillar: IOException while loading package org.renjin.cran:crayon: Cannot run program "tput" (in directory "D:\git\renjin-ggplot2"): CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:191)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:143)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
at org.renjin.primitives.packaging.Packages.library(Packages.java:39)
at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:68)
at org.renjin.primitives.R$primitive$library.applyPromised(R$primitive$library.java:33)
at org.renjin.sexp.BuiltinFunction.apply(BuiltinFunction.java:100)
at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:46)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.eval.Context.evaluate(Context.java:282)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:39)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.sexp.Closure.applyPromised(Closure.java:200)
at org.renjin.sexp.Closure.apply(Closure.java:133)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.sexp.ExpressionVector.eval(ExpressionVector.java:85)
at org.renjin.eval.Context.evaluate(Context.java:282)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:168)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:127)
at Test.main(Test.java:13)
这是由评估库调用的语句生成的。非常感谢。