Market Basket Analysis in R

Given below are few observations from my data set

structure(list(p1 = c(1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L), 
    p2 = c(1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 0L), p3 = c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L), p4 = c(1L, 1L, 1L, 1L, 
    1L, 0L, 1L, 0L, 0L, 0L)), .Names = c("p1", "p2", "p3", "p4"
), row.names = c(NA, -10L), class = "data.frame")

The column name depict a type of skill in a project required by 1 in front of that project row. I want to create a common basket of skills which occur together for maximum number of projects. Is there any way of doing market basket analysis on the given data in R? Or any way to solve the above problem.

Answers


Check out the arules package:

library(arules)
trans <-  as(as.matrix(df), "transactions")
rules <- apriori(trans, parameter = list(supp = 0.01, conf = 0.1, target = "rules", minlen=2))
inspect(sort(rules[1:5], by="confidence"))
#   lhs     rhs  support confidence      lift
# 1 {p1} => {p2}     0.2  0.5000000 1.0000000
# 2 {p1} => {p3}     0.2  0.5000000 0.7142857
# 3 {p2} => {p1}     0.2  0.4000000 1.0000000
# 4 {p1} => {p4}     0.1  0.2500000 0.4166667
# 5 {p4} => {p1}     0.1  0.1666667 0.4166667

Need Your Help

Zend Framework Routing: .html extension

php zend-framework url url-routing

I know I've seen this done before but I can't find the information anywhere. I need to be able to route with .html extensions in the Zend Framework.

Echo command in makefile not printing

makefile gnu-make

I have the following Makefile, with a rule which checks for dependencies: