1.Instalar paquetes y llamar librerías.

#install.packages("plyr")
library(plyr)
#install.packages("Matrix")
library(Matrix)
#install.packages("arules")
library(arules)
## 
## Attaching package: 'arules'
## The following objects are masked from 'package:base':
## 
##     abbreviate, write
#install.packages("arulesViz")
library(arulesViz)
#install.packages("datasets")
library(datasets)

2.Importar la base de datos

#file.choose()
bd <- read.csv("/Users/emilianomartinezcorona/Desktop/Manipulación de datos/abarrotes_bdlimpia.csv")

3.Ordenar de menor a mayor los tickets

bd <- bd[order(bd$F.Ticket),]
head(bd)
##   vcClaveTienda  DescGiro      Fecha Hora                      Marca
## 1         MX001 Abarrotes 2020-06-19    8                NUTRI LECHE
## 2         MX001 Abarrotes 2020-06-19    8                     DAN UP
## 3         MX001 Abarrotes 2020-06-19    8                      BIMBO
## 4         MX001 Abarrotes 2020-06-19    8                      PEPSI
## 5         MX001 Abarrotes 2020-06-19    8 BLANCA NIEVES (DETERGENTE)
## 6         MX001 Abarrotes 2020-06-19    8                      FLASH
##                   Fabricante                           Producto Precio
## 1                    MEXILAC                Nutri Leche 1 Litro   16.0
## 2           DANONE DE MEXICO DANUP STRAWBERRY P/BEBER 350GR NAL   14.0
## 3                GRUPO BIMBO                Rebanadas Bimbo 2Pz    5.0
## 4        PEPSI-COLA MEXICANA                   Pepsi N.R. 400Ml    8.0
## 5 FABRICA DE JABON LA CORONA      Detergente Blanca Nieves 500G   19.5
## 6                       ALEN      Flash Xtra Brisa Marina 500Ml    9.5
##   Ult.Costo Unidades F.Ticket NombreDepartamento          NombreFamilia
## 1     12.31        1        1          Abarrotes Lacteos y Refrigerados
## 2     14.00        1        2          Abarrotes Lacteos y Refrigerados
## 3      5.00        1        3          Abarrotes         Pan y Tortilla
## 4      8.00        1        3          Abarrotes                Bebidas
## 5     15.00        1        4          Abarrotes     Limpieza del Hogar
## 6      7.31        1        4          Abarrotes     Limpieza del Hogar
##             NombreCategoria     Estado Mts.2 Tipo.ubicación      Giro
## 1                     Leche Nuevo León    60        Esquina Abarrotes
## 2                    Yogurt Nuevo León    60        Esquina Abarrotes
## 3     Pan Dulce Empaquetado Nuevo León    60        Esquina Abarrotes
## 4 Refrescos Plástico (N.R.) Nuevo León    60        Esquina Abarrotes
## 5                Lavandería Nuevo León    60        Esquina Abarrotes
## 6      Limpiadores Líquidos Nuevo León    60        Esquina Abarrotes
##   Hora.inicio Hora.cierre diadelasemana subtotal
## 1       08:00       22:00             6     16.0
## 2       08:00       22:00             6     14.0
## 3       08:00       22:00             6      5.0
## 4       08:00       22:00             6      8.0
## 5       08:00       22:00             6     19.5
## 6       08:00       22:00             6      9.5
tail(bd)
##        vcClaveTienda   DescGiro      Fecha Hora          Marca
## 107247         MX004 Carnicería 2020-10-15   11         YEMINA
## 167624         MX004 Carnicería 2020-10-15   11     DEL FUERTE
## 149282         MX004 Carnicería 2020-10-15   11 COCA COLA ZERO
## 168603         MX004 Carnicería 2020-10-15   11       DIAMANTE
## 161046         MX004 Carnicería 2020-10-15   12          PEPSI
## 112823         MX004 Carnicería 2020-10-15   12      COCA COLA
##                  Fabricante                       Producto Precio Ult.Costo
## 107247               HERDEZ    PASTA SPAGHETTI YEMINA 200G      7      5.38
## 167624 ALIMENTOS DEL FUERTE PURE DE TOMATE DEL FUERTE 345G     12      9.23
## 149282            COCA COLA           COCA COLA ZERO 600ML     15     11.54
## 168603           EMPACADOS              ARROZ DIAMANTE225G     11      8.46
## 161046  PEPSI-COLA MEXICANA              PEPSI N. R. 500ML     10      7.69
## 112823            COCA COLA     COCA COLA RETORNABLE 500ML     10      7.69
##        Unidades F.Ticket NombreDepartamento        NombreFamilia
## 107247        2   450032          Abarrotes       Sopas y Pastas
## 167624        1   450032          Abarrotes Salsas y Sazonadores
## 149282        2   450034          Abarrotes              Bebidas
## 168603        1   450037          Abarrotes    Granos y Semillas
## 161046        1   450039          Abarrotes              Bebidas
## 112823        8   450040          Abarrotes              Bebidas
##                      NombreCategoria  Estado Mts.2 Tipo.ubicación      Giro
## 107247 Fideos, Spaguetti, Tallarines Sinaloa    53        Esquina Abarrotes
## 167624          Salsa para Spaguetti Sinaloa    53        Esquina Abarrotes
## 149282         Refrescos Retornables Sinaloa    53        Esquina Abarrotes
## 168603                         Arroz Sinaloa    53        Esquina Abarrotes
## 161046     Refrescos Plástico (N.R.) Sinaloa    53        Esquina Abarrotes
## 112823         Refrescos Retornables Sinaloa    53        Esquina Abarrotes
##        Hora.inicio Hora.cierre diadelasemana subtotal
## 107247       07:00       23:00             5       14
## 167624       07:00       23:00             5       12
## 149282       07:00       23:00             5       30
## 168603       07:00       23:00             5       11
## 161046       07:00       23:00             5       10
## 112823       07:00       23:00             5       80

4.Extraer productos por ticket

basket <- ddply(bd, c("F.Ticket"), function(bd)paste(bd$Marca, collapse = ","))

5.Eliminar número de ticket

basket$F.Ticket <- NULL

6.Renombrar el nombre de la columna marca

colnames(basket) <- c("Marca")

7.Exportar basket

#write.csv(basket, "basket.csv", quote = FALSE, row.names = FALSE)

8.Importar transacciones

#file.choose()
tr <- read.transactions("/Users/emilianomartinezcorona/basket.csv", format = "basket", sep = ",")
## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string

## Warning in scan(text = l, what = "character", sep = sep, quote = quote, : EOF
## within quoted string
## Warning in asMethod(object): removing duplicated items in transactions

9.Generar reglas de asociación

reglas_asociacion <- apriori(tr, parameter = list(supp=0.001, conf=0.2, maxlen=10))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.2    0.1    1 none FALSE            TRUE       5   0.001      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 115 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[604 item(s), 115031 transaction(s)] done [0.03s].
## sorting and recoding items ... [207 item(s)] done [0.00s].
## creating transaction tree ... done [0.03s].
## checking subsets of size 1 2 3 done [0.00s].
## writing ... [11 rule(s)] done [0.00s].
## creating S4 object  ... done [0.01s].
summary(reglas_asociacion)
## set of 11 rules
## 
## rule length distribution (lhs + rhs):sizes
##  2 
## 11 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       2       2       2       2       2       2 
## 
## summary of quality measures:
##     support           confidence        coverage             lift       
##  Min.   :0.001017   Min.   :0.2069   Min.   :0.003564   Min.   : 1.326  
##  1st Qu.:0.001104   1st Qu.:0.2358   1st Qu.:0.004507   1st Qu.: 1.789  
##  Median :0.001417   Median :0.2442   Median :0.005807   Median : 3.972  
##  Mean   :0.001521   Mean   :0.2537   Mean   :0.006056   Mean   :17.558  
##  3rd Qu.:0.001652   3rd Qu.:0.2685   3rd Qu.:0.006894   3rd Qu.:21.808  
##  Max.   :0.002747   Max.   :0.3098   Max.   :0.010502   Max.   :65.862  
##      count      
##  Min.   :117.0  
##  1st Qu.:127.0  
##  Median :163.0  
##  Mean   :174.9  
##  3rd Qu.:190.0  
##  Max.   :316.0  
## 
## mining info:
##  data ntransactions support confidence
##    tr        115031   0.001        0.2
##                                                                         call
##  apriori(data = tr, parameter = list(supp = 0.001, conf = 0.2, maxlen = 10))
inspect(reglas_asociacion)
##      lhs                  rhs         support     confidence coverage   
## [1]  {FANTA}           => {COCA COLA} 0.001051890 0.2439516  0.004311881
## [2]  {SALVO}           => {FABULOSO}  0.001104050 0.3097561  0.003564257
## [3]  {FABULOSO}        => {SALVO}     0.001104050 0.2347505  0.004703080
## [4]  {COCA COLA ZERO}  => {COCA COLA} 0.001417009 0.2969035  0.004772627
## [5]  {SPRITE}          => {COCA COLA} 0.001347463 0.2069426  0.006511288
## [6]  {PINOL}           => {CLORALEX}  0.001017117 0.2368421  0.004294495
## [7]  {BLUE HOUSE}      => {BIMBO}     0.001712582 0.2720994  0.006293956
## [8]  {HELLMANN´S}      => {BIMBO}     0.001538716 0.2649701  0.005807130
## [9]  {REYMA}           => {CONVERMEX} 0.002095087 0.2441743  0.008580296
## [10] {FUD}             => {BIMBO}     0.001590876 0.2186380  0.007276299
## [11] {COCA COLA LIGHT} => {COCA COLA} 0.002747086 0.2615894  0.010501517
##      lift      count
## [1]   1.562646 121  
## [2]  65.862391 127  
## [3]  65.862391 127  
## [4]   1.901832 163  
## [5]   1.325583 155  
## [6]  25.063647 117  
## [7]   4.078691 197  
## [8]   3.971823 177  
## [9]  18.551922 241  
## [10]  3.277319 183  
## [11]  1.675626 316
reglas_asociacion <- sort(reglas_asociacion, by="confidence", decreasing = TRUE)
summary(reglas_asociacion)
## set of 11 rules
## 
## rule length distribution (lhs + rhs):sizes
##  2 
## 11 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       2       2       2       2       2       2 
## 
## summary of quality measures:
##     support           confidence        coverage             lift       
##  Min.   :0.001017   Min.   :0.2069   Min.   :0.003564   Min.   : 1.326  
##  1st Qu.:0.001104   1st Qu.:0.2358   1st Qu.:0.004507   1st Qu.: 1.789  
##  Median :0.001417   Median :0.2442   Median :0.005807   Median : 3.972  
##  Mean   :0.001521   Mean   :0.2537   Mean   :0.006056   Mean   :17.558  
##  3rd Qu.:0.001652   3rd Qu.:0.2685   3rd Qu.:0.006894   3rd Qu.:21.808  
##  Max.   :0.002747   Max.   :0.3098   Max.   :0.010502   Max.   :65.862  
##      count      
##  Min.   :117.0  
##  1st Qu.:127.0  
##  Median :163.0  
##  Mean   :174.9  
##  3rd Qu.:190.0  
##  Max.   :316.0  
## 
## mining info:
##  data ntransactions support confidence
##    tr        115031   0.001        0.2
##                                                                         call
##  apriori(data = tr, parameter = list(supp = 0.001, conf = 0.2, maxlen = 10))
inspect(reglas_asociacion)
##      lhs                  rhs         support     confidence coverage   
## [1]  {SALVO}           => {FABULOSO}  0.001104050 0.3097561  0.003564257
## [2]  {COCA COLA ZERO}  => {COCA COLA} 0.001417009 0.2969035  0.004772627
## [3]  {BLUE HOUSE}      => {BIMBO}     0.001712582 0.2720994  0.006293956
## [4]  {HELLMANN´S}      => {BIMBO}     0.001538716 0.2649701  0.005807130
## [5]  {COCA COLA LIGHT} => {COCA COLA} 0.002747086 0.2615894  0.010501517
## [6]  {REYMA}           => {CONVERMEX} 0.002095087 0.2441743  0.008580296
## [7]  {FANTA}           => {COCA COLA} 0.001051890 0.2439516  0.004311881
## [8]  {PINOL}           => {CLORALEX}  0.001017117 0.2368421  0.004294495
## [9]  {FABULOSO}        => {SALVO}     0.001104050 0.2347505  0.004703080
## [10] {FUD}             => {BIMBO}     0.001590876 0.2186380  0.007276299
## [11] {SPRITE}          => {COCA COLA} 0.001347463 0.2069426  0.006511288
##      lift      count
## [1]  65.862391 127  
## [2]   1.901832 163  
## [3]   4.078691 197  
## [4]   3.971823 177  
## [5]   1.675626 316  
## [6]  18.551922 241  
## [7]   1.562646 121  
## [8]  25.063647 117  
## [9]  65.862391 127  
## [10]  3.277319 183  
## [11]  1.325583 155
top10reglas <- head(reglas_asociacion, n=10, by="confidence")
plot(top10reglas, method="graph", engine="htmlwidget")

10.Estrategias de negocio

  • Asignar marcas cercanas en el anaquel: Salvo y Fabuloso.
  • Promoción en Reyma/Convermex, Pinol/Cloralex, Queso/Jamon/Maronesa, Zero/Light/Fanta.
  • Realizar business Case para venta de sandwiches preparados.
LS0tCnRpdGxlOiAiTWFya2V0IEJhc2tldCBBbmFseXNpcyBBYmFycm90ZXMiCmF1dGhvcjogIkVtaWxpYW5vIE1hcnTDrW5leiBDb3JvbmEgQTAxMDY3NDU2IgpkYXRlOiAiMjAyMy0wMy0xNyIKb3V0cHV0OgogIGh0bWxfZG9jdW1lbnQ6CiAgICB0b2M6IHRydWUKICAgIHRvY19mbG9hdDogdHJ1ZQogICAgY29kZV9kb3dubG9hZDogdHJ1ZQotLS0KIVtdKC9Vc2Vycy9lbWlsaWFub21hcnRpbmV6Y29yb25hL0Rlc2t0b3AvQ2FwdHVyYSBkZSBwYW50YWxsYSAyMDIzLTAzLTE2IGEgbGEocykgMTAuNTMuMzcgcC5tLi5wbmcpCgojIyMgMS5JbnN0YWxhciBwYXF1ZXRlcyB5IGxsYW1hciBsaWJyZXLDrWFzLgpgYGB7cn0KI2luc3RhbGwucGFja2FnZXMoInBseXIiKQpsaWJyYXJ5KHBseXIpCiNpbnN0YWxsLnBhY2thZ2VzKCJNYXRyaXgiKQpsaWJyYXJ5KE1hdHJpeCkKI2luc3RhbGwucGFja2FnZXMoImFydWxlcyIpCmxpYnJhcnkoYXJ1bGVzKQojaW5zdGFsbC5wYWNrYWdlcygiYXJ1bGVzVml6IikKbGlicmFyeShhcnVsZXNWaXopCiNpbnN0YWxsLnBhY2thZ2VzKCJkYXRhc2V0cyIpCmxpYnJhcnkoZGF0YXNldHMpCmBgYAoKIyMjIDIuSW1wb3J0YXIgb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