加载包 Rweka 时出现 Renjin IOException,找不到函数 '.jfield'

Renjin IOException while loading package Rweka, could not find function '.jfield'

我正在尝试在 Java 程序中执行 R 脚本,所有依赖项都使用 Maven 安装,但问题仍然存在。

在我研究解决这个问题的过程中,我发现jfield是rJava提供的一个函数,但我不确定rJava(Renjin包)是否实现了它。

¿有没有办法检查这个? ¿或者我遗漏了什么?

我的程序使用了这些库,Renjin 都支持:

我正在使用 betadriven public repo 通过 Maven 来安装它们。 这是主要的 class:

package org.dfont.renjin;

import org.renjin.script.RenjinScriptEngineFactory;
import javax.script.ScriptEngine;


public class TryRenjin {
    public static void main(String[] args) throws Exception {
        // create a script engine manager:
        RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
        // create a Renjin engine:
        ScriptEngine engine = factory.getScriptEngine();

        // ... put your Java code here ...
        if(engine == null) {
            throw new RuntimeException("Renjin Script Engine not found on the classpath.");
        }

        else{
            engine.eval(new java.io.FileReader("/home/dfont/renjinTest/pruebaCalculo.R"));

        }
    }
}

这是我的 pom.xml,

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.dfont.renjin</groupId>
    <artifactId>renjin</artifactId>
    <version>0.1</version>
    <dependencies>
        <dependency>
            <groupId>org.renjin</groupId>
            <artifactId>renjin-script-engine</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.renjin.cran</groupId>
            <artifactId>rJava</artifactId>
            <version>0.9-8-renjin-5</version>
        </dependency>
        <dependency>
            <groupId>org.renjin.cran</groupId>
            <artifactId>RWekajars</artifactId>
            <version>3.9.1-3-b3</version>
        </dependency>
        <dependency>
            <groupId>org.renjin.cran</groupId>
            <artifactId>RWeka</artifactId>
            <version>0.4-34-b5</version>
        </dependency>


    </dependencies>
    <repositories>
        <repository>
            <id>bedatadriven</id>
            <name>bedatadriven public repo</name>
            <url>https://nexus.bedatadriven.com/content/groups/public/</url>
        </repository>
    </repositories>
    <build>
        <plugins>
            <plugin>
                <!-- Build an executable JAR -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>org.dfont.renjin.TryRenjin</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

我运行程序时第一行输出:

Exception in thread "main" org.renjin.eval.EvalException: IOException while loading package org.renjin.cran:RWeka: could not find function '.jfield'

提前致谢!

Renjin 还没有完全支持 rJava 包。似乎缺少的东西之一是 .jfield 的包装器。您可以在此处找到兼容层:

https://github.com/bedatadriven/renjin-rjava/blob/master/src/main/R/rJava.R

欢迎请求请求!