如何解决"错误:尚未支持长向量:qap_encode.c:36"?

时间:2018-05-30 11:40:59

标签: java r rstudio rjava rserve

我正在尝试使用Rserve

连接java和R.

Java:1.8.0_151
R:3.5.0
操作系统:Mac 10.13.4 HighSierra

要将R与Java连接,我在RStudio上输入以下内容

install.packages("Rserve")
library(Rserve)
Rserve(args="--no-save")
事情进展顺利,我很高兴。

然后我跳回到Java(可以说是Java Eclipse)并继续输入。这是我在Eclipse上所做的事情

package rserve;

import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.REngineException;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;

public class WordCloud1 {
    public static void main(String[] args) throws REngineException, 
REXPMismatchException {
    RConnection c = new RConnection();
    String path = "/Users/JinhoShin/Desktop/study/R/r_temp2";
    String file = "seoul_new.txt";
    c.parseAndEval("library(KoNLP)");
    c.parseAndEval("useSejongDic()");
    c.parseAndEval("library(wordcloud)");
    c.parseAndEval("library(RColorBrewer)");
    c.parseAndEval("setwd('" + path + "')");
    c.parseAndEval("data1=readLines('" + file + "')");
    c.parseAndEval("data2 = sapply(data1,extractNoun,USE.NAMES=F)");
    c.parseAndEval("data3 = unlist(data2)");
    c.parseAndEval("data3=gsub('seoul','',data3)");
    c.parseAndEval("data3=gsub('request','',data3)");
    c.parseAndEval("data3=gsub('place','',data3)");
    c.parseAndEval("data3=gsub('transportation','',data3)");
    c.parseAndEval("data3=gsub(' ','',data3)");
    c.parseAndEval("data3=gsub('-','',data3)");
    c.parseAndEval("data3=gsub('OO','',data3)");
    c.parseAndEval("write(unlist(data3),'seoul_2.txt')");
    c.parseAndEval("data4 = read.table('seoul_2.txt')"); ########this is what blows me up
    c.parseAndEval("wordcount=table(data4)");
    c.parseAndEval("palete = brewer.pal(9,'Set3')");
    c.parseAndEval(
            "wordcloud(names(wordcount),freq = wordcount,scale=c(5,1),rot.per=0.25, min.freq = 1," + 
            " random.order=F, random.color = T, colors=palete)");
    c.parseAndEval("savePlot('0517seoul.png', type = 'png')");
    c.parseAndEval("dev.off()");
    c.close();
}
}
正如您从代码中注意到的那样

 c.parseAndEval("data4 = read.table('seoul_2.txt')"); => at rserve.WordCloud1.main(WordCloud1.java:30)

我不知道为什么它无法读取我的文本文件,尽管它可以写入该文件。

这就是Java Eclipse控制台不断向我展示的内容

Exception in thread "main" org.rosuda.REngine.REngineException: eval failed
    at org.rosuda.REngine.Rserve.RConnection.parseAndEval(RConnection.java:499)
    at org.rosuda.REngine.REngine.parseAndEval(REngine.java:108)
    at rserve.WordCloud1.main(WordCloud1.java:30)
Caused by: org.rosuda.REngine.Rserve.RserveException: eval failed
    at org.rosuda.REngine.Rserve.RConnection.eval(RConnection.java:261)
    at org.rosuda.REngine.Rserve.RConnection.parseAndEval(RConnection.java:497)
    ... 2 more

这就是RStudio一直向我展示的

Error: long vectors not supported yet: qap_encode.c:36
Fatal error: unable to initialize the JIT

我尽我所能来解决这个问题,但我仍然在同一个地方。

0 个答案:

没有答案