球球大神指导!在用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