data(iris)
head(iris)
### convert continuous variables into categories
### default (4 categories - 0-25%, 25-50%, 50-75% and 75-100% quantiles)
iris[,1] <- categorize(iris[,1])
### specify quantiles
iris[,2] <- categorize(iris[,2], breaks=c(0,.25,.75,1))
### specify absolute boundaries
iris[,3] <- categorize(iris[,3], breaks=c(0,1,2,3,4,5,6,7), quantile=FALSE)
### name categories
iris[,4] <- categorize(iris[,4], breaks=3, quantile=FALSE,
labels=c("short", "medium", "long"))
head(iris)
### convert dataset into transactions
tr <- as(iris, "transactions")
tr
### mine and inspect rules
rules<-apriori(tr)
inspect(head(sort(rules, by="lift")))
Run the code above in your browser using DataLab