This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.
plot(cars)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
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
library(ggplot2)
library(readxl)
df <- read.csv("/Users/KarlaCastillo/Desktop/Datos/Abarrotes_Ventas.csv")
summary(df)
## vcClaveTienda DescGiro Codigo.Barras PLU
## Length:200620 Length:200620 Min. :8.347e+05 Min. : 1.00
## Class :character Class :character 1st Qu.:7.500e+12 1st Qu.: 1.00
## Mode :character Mode :character Median :7.500e+12 Median : 1.00
## Mean :5.949e+12 Mean : 2.11
## 3rd Qu.:7.500e+12 3rd Qu.: 1.00
## Max. :1.750e+13 Max. :30.00
## NA's :199183
## Fecha Hora Marca Fabricante
## Length:200620 Length:200620 Length:200620 Length:200620
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## Producto Precio Ult.Costo Unidades
## Length:200620 Min. :-147.00 Min. : 0.38 Min. : 0.200
## Class :character 1st Qu.: 11.00 1st Qu.: 8.46 1st Qu.: 1.000
## Mode :character Median : 16.00 Median : 12.31 Median : 1.000
## Mean : 19.42 Mean : 15.31 Mean : 1.262
## 3rd Qu.: 25.00 3rd Qu.: 19.23 3rd Qu.: 1.000
## Max. :1000.00 Max. :769.23 Max. :96.000
##
## F.Ticket NombreDepartamento NombreFamilia NombreCategoria
## Min. : 1 Length:200620 Length:200620 Length:200620
## 1st Qu.: 33967 Class :character Class :character Class :character
## Median :105996 Mode :character Mode :character Mode :character
## Mean :193994
## 3rd Qu.:383008
## Max. :450040
##
## Estado Mts.2 Tipo.ubicacion Giro
## Length:200620 Min. :47.0 Length:200620 Length:200620
## Class :character 1st Qu.:53.0 Class :character Class :character
## Mode :character Median :60.0 Mode :character Mode :character
## Mean :56.6
## 3rd Qu.:60.0
## Max. :62.0
##
## Hora.inicio Hora.cierre
## Length:200620 Length:200620
## Class :character Class :character
## Mode :character Mode :character
##
##
##
##
count(df,vcClaveTienda,sort=TRUE)
count(df,DescGiro,sort=TRUE)
count(df,Marca,sort=TRUE)
count(df,Fabricante,sort=TRUE)
count(df,Producto,sort=TRUE)
count(df,NombreDepartamento,sort=TRUE)
count(df,NombreFamilia,sort=TRUE)
count(df,NombreCategoria,sort=TRUE)
count(df,Estado,sort=TRUE)
count(df,Mts.2,sort=TRUE)
count(df,Tipo.ubicacion,sort=TRUE)
count(df,Giro,sort=TRUE)
count(df,Hora.inicio,sort=TRUE)
count(df,Hora.cierre,sort=TRUE)
table(df$NombreDepartamento)
##
## Abarrotes Bebes e Infantiles Carnes
## 198274 1483 1
## Farmacia Ferreter\xeda Mercer\xeda
## 255 377 44
## Papeler\xeda Productos a Eliminar Vinos y Licores
## 74 8 104
table(df$Estado)
##
## Chiapas Jalisco Nuevo Le\xf3n Quintana Roo Sinaloa
## 4051 6629 96464 10021 83455
library(janitor)
##
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
tabla1 <- tabyl(df, vcClaveTienda, NombreDepartamento)
## Warning in grep("^[.][.](?:[.]|[1-9][0-9]*)$", names): unable to translate
## 'Ferreter<ed>a' to a wide string
## Warning in grep("^[.][.](?:[.]|[1-9][0-9]*)$", names): input string 5 is
## invalid
## Warning in grep("^[.][.](?:[.]|[1-9][0-9]*)$", names): unable to translate
## 'Mercer<ed>a' to a wide string
## Warning in grep("^[.][.](?:[.]|[1-9][0-9]*)$", names): input string 6 is
## invalid
## Warning in grep("^[.][.](?:[.]|[1-9][0-9]*)$", names): unable to translate
## 'Papeler<ed>a' to a wide string
## Warning in grep("^[.][.](?:[.]|[1-9][0-9]*)$", names): input string 7 is
## invalid
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")
boxplot(df$Precio, horizontal = TRUE)
boxplot(df$Unidades, horizontal= TRUE)