Posts

Analysis in R

Image
Market Basket Analysis   Market Basket Analysis is a modelling technique based upon the theory that if you buy a certain group of items, you are more (or less) likely to buy another group of items. For example, if you are in an English pub and you buy a pint of beer and don't buy a bar meal, you are more likely to buy chips at the same time than somebody who didn't buy beer. Inspect the data : getwd() setwd("C:/Users/student.ASH05.000/Desktop/R") data <- readLines("groceries.csv") summary(data) str(data)                            transactions <- data.frame(   'ID' = NA,   'Product' = NA ) #adding data into transactions by treversing the vectors rownum <- nrow(transactions) for(i in 1:length(data)){   for (item in strsplit(data[i],',')[[1]]){     transactions[rownum+1,] = list(i,item)     rownum <- rownum + 1   } } transactions <- transactions[-1,] str(tra