1

我开始在 R 中与 Weka 合作,但我在第一步被卡住了。我将csv文件转换为arff文件,并使用在线转换器执行此操作,但是当我尝试将其读入 RI 时收到以下错误消息。

  require(RWeka)
  A <- read.arff("Environmental variables all overviewxlsx.arff")
Error in .jnew("weka/core/Instances", .jcast(reader, "java/io/Reader")) : 
 java.io.IOException: no valid attribute type or invalid enumeration, read Token[[°C]],    line 6 

有没有人有可以帮助我的想法?

谢谢!

ps 正确的包(RWeka)已经安装。

4

1 回答 1

2

因为 read.arff() 返回一个数据帧,您可以跳过转换过程并使用 read.csv()。

    train_arff<-read.arff(file.choose())
    str(train_arff)

    'data.frame':   14 obs. of  5 variables:
    $ outlook    : Factor w/ 3 levels "sunny","overcast",..: 1 1 2 3 3 3 2 1 1 3 ...
    $ temperature: Factor w/ 3 levels "hot","mild","cool": 1 1 1 2 3 3 3 2 3 2 ...
    $ humidity   : Factor w/ 2 levels "high","normal": 1 1 1 1 2 2 2 1 2 2 ...
    $ windy      : logi  FALSE TRUE FALSE FALSE FALSE TRUE ...
    $ play       : Factor w/ 2 levels "yes","no": 2 2 1 1 1 2 1 2 1 1 ...

    train_csv<-read.csv(file.choose())
    str(train_csv)

    'data.frame':   14 obs. of  5 variables:
    $ outlook    : Factor w/ 3 levels "overcast","rainy",..: 3 3 1 2 2 2 1 3 3 2 ...
    $ temperature: Factor w/ 3 levels "cool","hot","mild": 2 2 2 3 1 1 1 3 1 3 ...
    $ humidity   : Factor w/ 2 levels "high","normal": 1 1 1 1 2 2 2 1 2 2 ...
    $ windy      : logi  FALSE TRUE FALSE FALSE FALSE TRUE ...
    $ play       : Factor w/ 2 levels "no","yes": 1 1 2 2 2 1 2 1 2 2 ...

否则你的 .arff 文件应该有这种格式

于 2013-10-01T23:02:41.770 回答