ggjj在河之洲 2018-10-29 15:55 采纳率: 0%
浏览 3533
已结题

R语言,transactions函数提示“ arguments must have same length”

球球大神指导!在用R语言做关联性分析的时候,transactions函数总是出错!
我的代码是这样的:
library(xlsx)
read.xlsx2(file="C:\Users\18092\Desktop\LL.xlsx",sheetIndex=1)
library(arules)
library(arulesViz)#Load packages
dt<-read.table("C:/Users/18092/Desktop/LL.xlsx",header=T)#import data
LL<-as(dt,"transactions")#convert data.frame to transactions
rules=apriori("C:/Users/18092/Desktop/LL.xlsx",parameter=list(support=0.2,confidence=0.6,minlen=2,maxlen=2))#find association rules
summary(rules)
inspect(x[1:10])#show the first ten rules
错误是这样的:

library(arules)
library(arulesViz)#Load packages
dt<-read.table("C:/Users/18092/Desktop/LL.xlsx",header=T)#import data
Warning messages:
1: In read.table("C:/Users/18092/Desktop/LL.xlsx", header = T) :
line 1 appears to contain embedded nulls
2: In read.table("C:/Users/18092/Desktop/LL.xlsx", header = T) :
incomplete final line found by readTableHeader on 'C:/Users/18092/Desktop/LL.xlsx'
LL<-as(dt,"transactions")#convert data.frame to transactions
Error in tapply(p, x, eval, simplify = FALSE) :
arguments must have same length
rules=apriori("C:/Users/18092/Desktop/LL.xlsx",parameter=list(support=0.2,confidence=0.6,minlen=2,maxlen=2))#find association rules
Error in as(data, "transactions") :
no method or default for coercing “character” to “transactions”
summary(rules)
Error in summary(rules) : object 'rules' not found
#x=sort(subset(rules,subset=1hs%pin%"=TURE"&rhs%pin%"=TRUE"&lift>=1),by="support")#pick out the association needed and sort by support
inspect(x[1:10])#show the first ten rules
Error in inspect(x[1:10]) : object 'x' not found

  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2018-10-31 14:34
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B