这是个人记录,因为谷歌很难解决这个问题,我想几年后我还会再次遇到这个问题。
我的剧本是这样的:
library(FSelector)
table <- read.csv("somefile", header=0);
table <- table[,colSums(is.na(table))<nrow(table)]
imputed_table <- apply(table, 2, function(x){x <- replace(x, is.na(x), mean(x, na.rm=TRUE))});
nms <- colnames(table)
model <- information.gain(as.formula(paste(nms[length(nms)],"~.")), table)当运行时:
R --no-save < IG.R这很好,并打印模型。
当运行时:
Rscript ./IG.R这与错误崩溃:
Error in .jarray(x) : could not find function "getClass"
Calls: information.gain ... read_model_frame_into_Weka -> read_data_into_Weka -> .jcall -> .jarray -> .Call
Execution halted这一切为什么要发生?
发布于 2013-07-25 19:51:23
这是因为Rscript默认不加载rJava库,这是FSelector所需要的,但是在加载FSelector时显然没有加载。相反,标准的"R“命令默认情况下确实加载rJava。
要解决这一问题,请添加:
library(rJava)到information.gain调用之前的脚本。
https://stackoverflow.com/questions/17867464
复制相似问题