我有一个试图
的R脚本vec size = 3x2
load.R
当我跑步时:
load("test.RData")
发生异常:
engine.eval(new FileReader("load.R"))
我不知道R.我只是试图使用R代码使用Renjin在Java / Scala应用程序中处理一些数据。
阅读documention上的数据部分没有说明从 Exception in thread "main" java.lang.NoClassDefFoundError: org/tukaani/xz/XZInputStream
at org.renjin.primitives.io.connections.Connections.gzfile(Connections.java:79)
at org.renjin.primitives.R$primitive$gzfile.doApply(R$primitive$gzfile.java:75)
at org.renjin.primitives.R$primitive$gzfile.apply(R$primitive$gzfile.java:36)
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.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.primitives.special.AssignLeftFunction.assignLeft(AssignLeftFunction.java:57)
at org.renjin.primitives.special.AssignLeftFunction.apply(AssignLeftFunction.java:41)
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.primitives.special.IfFunction.apply(IfFunction.java:40)
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:145)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:104)
at com.infosistema.imp.restservice.data_treatment.DataTreatment.<init>(DataTreatment.scala:34)
at com.infosistema.imp.restservice.data_treatment.Main$.<init>(DataTreatment.scala:45)
at com.infosistema.imp.restservice.data_treatment.Main$.<clinit>(DataTreatment.scala)
at com.infosistema.imp.restservice.data_treatment.Main.main(DataTreatment.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.tukaani.xz.XZInputStream
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 46 more
文件加载数据。
更新:
在我的.RData
文件中,我有:
build.sbt
答案 0 :(得分:1)
在你的类路径上只有renjin-script-engine.jar是不够的,你也需要它的依赖。
如果您使用SBT构建Scala项目,则需要将以下内容添加到构建文件中:
resolvers +=
"BeDataDriven" at "https://nexus.bedatadriven.com/content/groups/public"
lazy val root = (project in file(".")).
settings(
name := "renjin-test",
version := "1.0",
scalaVersion := "2.10.6",
libraryDependencies += "org.renjin" % "renjin-script-engine" % "0.8.1886"
)
有关其他构建工具,请参阅: http://docs.renjin.org/en/latest/library/project-setup.html
答案 1 :(得分:0)
问题是coursier
无法解决所有依赖关系(没有任何通知)。
从addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
删除plugins.sbt
并使用sbt的默认解析程序修复了此问题。