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
I had this issue too and then realized that I forgot to load the library with
library(arulesViz)
after installing the package with:
install.packages("arulesViz")
This problem is caused by library installed incomplete(I guess it might put the wrong name(version) in the pack of arulesViz).
You can download https://cran.rstudio.com/bin/windows/contrib/3.3/seriation_1.2-1.zip
manually,then use "r-studio menu -> tools -> install packages.." to install above zip file downloaded from the site.
Then try to redo install.packages("arulesViz")
and library(arulesViz), it will be workable.
Done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With