楼主: BBS66
1805 1

[问答] 请教一个R语言的问题,报错Error in slot(x, s)[i] : subscript out of bounds [推广有奖]

  • 0关注
  • 0粉丝

等待验证会员

小学生

28%

还不是VIP/贵宾

-

威望
0
论坛币
7 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
56 点
帖子
5
精华
0
在线时间
0 小时
注册时间
2018-10-13
最后登录
2018-10-13

3论坛币
救救孩子吧
> library(arules)
载入需要的程辑包:Matrix

载入程辑包:‘arules’

The following objects are masked from ‘package:base’:

    abbreviate, write

> library(arulesViz)
载入需要的程辑包:grid
> dt<-read.table("mba.txt",header=T)
> mba<-as(dt,"transactions")
> rules=apriori(mba,parameter=list(support=0.03,confidence=0.4,minlen=2,maxlen=2))
Apriori

Parameter specification:
confidence minval smax arem  aval originalSupport
        0.4    0.1    1 none FALSE            TRUE
maxtime support minlen maxlen target   ext
       5    0.03      2      2  rules FALSE

Algorithmic control:
filter tree heap memopt load sort verbose
    0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 5

set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[27 item(s), 179 transaction(s)] done [0.00s].
sorting and recoding items ... [22 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 2 done [0.00s].
writing ... [19 rule(s)] done [0.00s].
creating S4 object  ... done [0.00s].
Warning message:
In apriori(mba, parameter = list(support = 0.03, confidence = 0.4,  :
  Mining stopped (maxlen reached). Only patterns up to a length of 2 returned!
> summary(rules)
set of 19 rules

rule length distribution (lhs + rhs):sizes
2
19

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
      2       2       2       2       2       2

summary of quality measures:
    support          confidence          lift      
Min.   :0.03352   Min.   :0.4048   Min.   :1.362  
1st Qu.:0.10056   1st Qu.:0.4988   1st Qu.:1.637  
Median :0.16760   Median :0.6122   Median :2.275  
Mean   :0.14760   Mean   :0.6505   Mean   :2.216  
3rd Qu.:0.17318   3rd Qu.:0.7941   3rd Qu.:2.578  
Max.   :0.31844   Max.   :0.9661   Max.   :3.236  
     count      
Min.   : 6.00  
1st Qu.:18.00  
Median :30.00  
Mean   :26.42  
3rd Qu.:31.00  
Max.   :57.00  

mining info:
data ntransactions support confidence
  mba           179    0.03        0.4
> x=sort(subset(rules,subset=lhs%pin%"=TRUE"&rhs%pin%"=TRUE"&lift>=1),by="support")
> inspect(x[1:10])
Error in slot(x, s) : subscript out of bounds
mba.txt (9.8 KB)

关键词:R语言
帮露朱顶一下~~~希望有大牛能够帮到你

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-3 18:35