poblacion <- read.csv("poblacion.csv")
muestra <- read.csv("muestra.csv")
N <- length(poblacion$Pago)
n <- length(muestra$Pago)
media_poblacional <- mean(poblacion$Pago)
media_poblacional
## [1] 245.0167
media_muestral <- mean(muestra$Pago)
media_muestral
## [1] 249.432
mediana_poblacional <- median(poblacion$Pago)
mediana_poblacional
## [1] 228.63
mediana_muestral <- median(muestra$Pago)
mediana_muestral
## [1] 230.46
moda <- function(x){
ux <- unique(x)
ux[which.max(tabulate(match(x, ux)))]
}
moda_poblacional <- moda(poblacion$Pago)
moda_poblacional
## [1] 266.63
moda_muestral <- moda(muestra$Pago)
moda_muestral
## [1] 266.63
mtc_poblacional <- c(media_poblacional, mediana_poblacional, moda_poblacional)
names(mtc_poblacional)<- c("media_poblacional", "mediana_poblacional", "moda_poblacional")
mtc_poblacional <- sort(mtc_poblacional)
mtc_poblacional
## mediana_poblacional media_poblacional moda_poblacional
## 228.6300 245.0167 266.6300
hist(poblacion$Pago)
rango_poblacional<- max(poblacion$Pago) - min(poblacion$Pago)
rango_poblacional
## [1] 180.86
rango_muestral <- max(muestra$Pago) - min(muestra$Pago)
rango_muestral
## [1] 156.34
varianza_poblacional <- var(poblacion$Pago)*(N-1)/N
varianza_poblacional
## [1] 3614.659
varianza_muestral <- var(muestra$Pago)
varianza_muestral
## [1] 3570.905
desv_pob <- sqrt(varianza_poblacional)
desv_pob
## [1] 60.12203
desv_m <- sqrt(varianza_muestral)
desv_m
## [1] 59.75705
library(readxl)
library(janitor)
##
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
df <- read_excel("Abarrotes_Ventas.xlsx")
summary(df)
## vcClaveTienda DescGiro Codigo Barras PLU
## Length:200620 Length:200620 Min. :8.347e+05 Mode:logical
## Class :character Class :character 1st Qu.:7.501e+12 TRUE:1437
## Mode :character Mode :character Median :7.501e+12 NA's:199183
## Mean :5.950e+12
## 3rd Qu.:7.501e+12
## Max. :1.750e+13
## Fecha Hora
## Min. :2020-05-01 00:00:31.08 Min. :1899-12-31 00:00:00.00
## 1st Qu.:2020-06-06 13:24:49.08 1st Qu.:1899-12-31 13:12:42.75
## Median :2020-07-11 14:10:21.46 Median :1899-12-31 17:35:59.00
## Mean :2020-07-19 15:19:40.65 Mean :1899-12-31 16:43:52.05
## 3rd Qu.:2020-08-29 22:07:47.33 3rd Qu.:1899-12-31 20:47:06.00
## Max. :2020-11-11 23:53:47.73 Max. :1899-12-31 23:59:59.00
## Marca Fabricante Producto Precio
## Length:200620 Length:200620 Length:200620 Min. :-147.00
## Class :character Class :character Class :character 1st Qu.: 11.00
## Mode :character Mode :character Mode :character Median : 16.00
## Mean : 19.42
## 3rd Qu.: 25.00
## Max. :1000.00
## Ult.Costo Unidades F.Ticket NombreDepartamento
## Min. : 0.38 Min. : 0.200 Min. : 1 Length:200620
## 1st Qu.: 8.46 1st Qu.: 1.000 1st Qu.: 33967 Class :character
## Median : 12.31 Median : 1.000 Median :105996 Mode :character
## Mean : 15.31 Mean : 1.262 Mean :193994
## 3rd Qu.: 19.23 3rd Qu.: 1.000 3rd Qu.:383009
## Max. :769.23 Max. :96.000 Max. :450040
## NombreFamilia NombreCategoria Estado Mts 2
## Length:200620 Length:200620 Length:200620 Min. :47.0
## Class :character Class :character Class :character 1st Qu.:53.0
## Mode :character Mode :character Mode :character Median :60.0
## Mean :56.6
## 3rd Qu.:60.0
## Max. :62.0
## Tipo ubicación Giro Hora inicio
## Length:200620 Length:200620 Min. :1899-12-31 07:00:00.00
## Class :character Class :character 1st Qu.:1899-12-31 07:00:00.00
## Mode :character Mode :character Median :1899-12-31 08:00:00.00
## Mean :1899-12-31 07:35:49.71
## 3rd Qu.:1899-12-31 08:00:00.00
## Max. :1899-12-31 09:00:00.00
## Hora cierre
## Min. :1899-12-31 21:00:00.00
## 1st Qu.:1899-12-31 22:00:00.00
## Median :1899-12-31 22:00:00.00
## Mean :1899-12-31 22:23:11.42
## 3rd Qu.:1899-12-31 23:00:00.00
## Max. :1899-12-31 23:00:00.00
count(df,DescGiro, sort=T)
## # A tibble: 3 × 2
## DescGiro n
## <chr> <int>
## 1 Abarrotes 100515
## 2 Carnicería 83455
## 3 Depósito 16650
count(df,Marca, sort=T)
## # A tibble: 540 × 2
## Marca n
## <chr> <int>
## 1 COCA COLA 18686
## 2 PEPSI 15966
## 3 TECATE 11674
## 4 BIMBO 8316
## 5 LALA 5866
## 6 MARINELA 3696
## 7 DORITOS 3142
## 8 CHEETOS 3130
## 9 NUTRI LECHE 3127
## 10 MARLBORO 2579
## # ℹ 530 more rows
count(df,Fabricante, sort=T)
## # A tibble: 241 × 2
## Fabricante n
## <chr> <int>
## 1 COCA COLA 27519
## 2 PEPSI-COLA MEXICANA 22415
## 3 SABRITAS 14296
## 4 CERVECERIA CUAUHTEMOC MOCTEZUMA 13681
## 5 GRUPO BIMBO 13077
## 6 SIGMA ALIMENTOS 8014
## 7 GRUPO INDUSTRIAL LALA 5868
## 8 GRUPO GAMESA 5527
## 9 NESTLE 3698
## 10 JUGOS DEL VALLE S.A. DE C.V. 3581
## # ℹ 231 more rows
count(df,Producto, sort=T)
## # A tibble: 3,404 × 2
## Producto n
## <chr> <int>
## 1 Pepsi N.R. 1.5L 5108
## 2 Coca Cola Retornable 2.5L 3771
## 3 Caguamon Tecate Light 1.2Lt 3471
## 4 Pepsi N. R. 2.5L 2899
## 5 Cerveza Tecate Light 340Ml 2619
## 6 Cerveza Tecate Light 16Oz 2315
## 7 Coca Cola Retornable 1.5L 2124
## 8 Pepsi N.R. 3L 1832
## 9 Coca Cola Retornable 500Ml 1659
## 10 PEPSI N.R. 1.5L 1631
## # ℹ 3,394 more rows
count(df,NombreFamilia, sort=T)
## # A tibble: 51 × 2
## NombreFamilia n
## <chr> <int>
## 1 Bebidas 64917
## 2 Botanas 21583
## 3 Lacteos y Refrigerados 17657
## 4 Cerveza 14017
## 5 Pan y Tortilla 10501
## 6 Limpieza del Hogar 8723
## 7 Galletas 7487
## 8 Cigarros 6817
## 9 Cuidado Personal 5433
## 10 Salsas y Sazonadores 5320
## # ℹ 41 more rows
count(df,NombreCategoria, sort=T)
## # A tibble: 174 × 2
## NombreCategoria n
## <chr> <int>
## 1 Refrescos Plástico (N.R.) 32861
## 2 Refrescos Retornables 13880
## 3 Frituras 11082
## 4 Lata 8150
## 5 Leche 7053
## 6 Cajetilla 6329
## 7 Botella 5867
## 8 Productos sin Categoria 5455
## 9 Papas Fritas 5344
## 10 Jugos y Néctares 5295
## # ℹ 164 more rows
count(df,NombreDepartamento, sort=T)
## # A tibble: 9 × 2
## NombreDepartamento n
## <chr> <int>
## 1 Abarrotes 198274
## 2 Bebes e Infantiles 1483
## 3 Ferretería 377
## 4 Farmacia 255
## 5 Vinos y Licores 104
## 6 Papelería 74
## 7 Mercería 44
## 8 Productos a Eliminar 8
## 9 Carnes 1
count(df,Estado, sort=T)
## # A tibble: 5 × 2
## Estado n
## <chr> <int>
## 1 Nuevo León 96464
## 2 Sinaloa 83455
## 3 Quintana Roo 10021
## 4 Jalisco 6629
## 5 Chiapas 4051
count(df,"Mts 2", sort=T)
## # A tibble: 1 × 2
## `"Mts 2"` n
## <chr> <int>
## 1 Mts 2 200620
count(df,"Tipo ubicación", sort=T)
## # A tibble: 1 × 2
## `"Tipo ubicación"` n
## <chr> <int>
## 1 Tipo ubicación 200620
count(df,Giro, sort=T)
## # A tibble: 2 × 2
## Giro n
## <chr> <int>
## 1 Abarrotes 183970
## 2 Mini súper 16650
count(df,Fecha, sort=T)
## # A tibble: 131,933 × 2
## Fecha n
## <dttm> <int>
## 1 2020-05-26 21:52:47 23
## 2 2020-07-16 09:44:01 20
## 3 2020-06-02 19:26:22 19
## 4 2020-06-07 12:11:25 19
## 5 2020-06-20 22:00:56 18
## 6 2020-08-22 14:00:07 18
## 7 2020-05-19 14:55:37 17
## 8 2020-05-31 15:12:58 17
## 9 2020-06-20 16:21:08 17
## 10 2020-08-17 21:30:06 17
## # ℹ 131,923 more rows
count(df,Hora, sort=T)
## # A tibble: 52,145 × 2
## Hora n
## <dttm> <int>
## 1 1899-12-31 21:52:47 30
## 2 1899-12-31 20:59:07 29
## 3 1899-12-31 12:11:26 28
## 4 1899-12-31 12:47:09 26
## 5 1899-12-31 14:55:38 26
## 6 1899-12-31 21:26:54 26
## 7 1899-12-31 21:30:07 25
## 8 1899-12-31 22:03:53 24
## 9 1899-12-31 18:46:35 23
## 10 1899-12-31 19:28:26 23
## # ℹ 52,135 more rows
tabla1 <-tabyl(df, vcClaveTienda, NombreDepartamento)
df$Subtotal <- df$Precio*df$Unidades
ggplot(df,aes(x=vcClaveTienda, y=Subtotal))+ geom_bar(stat="identity")
library(qcc)
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
tabla1 <- subset(tabla1, select= c(vcClaveTienda, Abarrotes))
pareto.chart(tabla1$Abarrotes)
##
## Pareto chart analysis for tabla1$Abarrotes
## Frequency Cum.Freq. Percentage Cum.Percent.
## A 9.541000e+04 9.541000e+04 4.812028e+01 4.812028e+01
## D 8.223400e+04 1.776440e+05 4.147493e+01 8.959521e+01
## E 1.001400e+04 1.876580e+05 5.050587e+00 9.464579e+01
## B 6.590000e+03 1.942480e+05 3.323683e+00 9.796948e+01
## C 4.026000e+03 1.982740e+05 2.030523e+00 1.000000e+02
plot(df$Precio,df$Unidades,main="Relación entre Precio y Unidades", xlab = "Precio", ylab="Unidades")
# Gráfico de caja y bigotes
boxplot(df$Precio, horizontal=T)
boxplot(df$Unidades, horizontal=T)