0

我是 R 的新手。

read.arff(file = "/Users/macbookpro/loving_eval_stem_stop_train.arff")

我正在运行这段代码,它似乎给了我这个异常

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  scan() expected 'a real', got '{21'

我确定我的绝对文件路径是正确的。我没有问题将文件读入 weka

4

1 回答 1

4

从您发布的内容来看,我怀疑这是一个稀疏格式的 ARFF 文件。我不确定您使用什么包将 arff 文件读入 R,但它可能不支持稀疏格式。

您可以尝试使用 weka 转换成完整格式的 arff 文件。(它可能会增加文件大小,但它应该成为 R 可读的。)

您可以使用此命令执行操作

java weka.filters.unsupervised.instance.SparseToNonSparse -i <input_file> -o <output_file> -c <index of class attribute>
于 2014-09-07T15:29:53.080 回答