I am applying Aprior algorithm, and while plotting there is an error.
I have installed packages arules
and arulesviz
.
The data has 3 attributes . Two were factorized and one attribute was not factorized. I have taken that attribute attribute separately and applied factor function. The code is below:
New_Train_Wifi = read.xlsx("D:/Train_Test.xls",1)
str(New_Train_Wifi)
'data.frame': 2201 obs. of 3 variables:
$ Wifi_ID: Factor w/ 4 levels "1st","2nd","3rd",..: 3 3 3 3 3 3 3 3 3 3 ...
$ Store : Factor w/ 5 levels "Book_Store","Clothing",..: 3 3 3 3 3 3 3 3 3 3 ...
$ Mac_ID : num 125 125 125 125 125 125 125 125 125 125 ...
A <- as.factor(Test_ARM_ABC$Wifi_ID)
C <- as.factor(New_Train_Wifi$Mac_ID)
New_Train_Wifi$MacID <- NULL
New_Train_Wifi$MacID <- C
New_Train_Wifi$Mac_ID <- NULL
class(New_Train_Wifi)
[1] "data.frame"
[1] "Wifi_ID" "Store" "MacID"
str(New_Train_Wifi)
'data.frame': 2201 obs. of 3 variables:
$ Wifi_ID: Factor w/ 4 levels "1st","2nd","3rd",..: 3 3 3 3 3 3 3 3 3 3 ...
$ Store : Factor w/ 5 levels "Book_Store","Clothing",..: 3 3 3 3 3 3 3 3 3 3 ...
$ MacID : Factor w/ 6 levels "100","125","254",..: 2 2 2 2 2 2 2 2 2 2 ...
rules <- apriori(New_Train_Wifi)
inspect(rules)
rules <- apriori(New_Train_Wifi, parameter = list(minlen = 2, supp = 0.10, conf = 0.8),
appearance = list(rhs = c("Wifi_ID=1st", "Wifi_ID=2nd", "Wifi_ID=3rd",
"Wifi_ID=4th"), default="lhs"), control = list(verbose = F))
> inspect(rules.sorted)
#/*Now wen I give below statement in r console */
> plot(rules)
Error in as.double(y) :
cannot coerce type 'S4' to vector of type 'double'
Above statement is the error I tried to but couldn't resolve . If anyone can resolve it, I will be really grateful.
The site that I referred to: http://www.rdatamining.com/examples/association-rules
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…