###Contexto

Para Arca Continental su principal canal de distribución es el canal tradicional, es decir, las tienditas de la esquina. Esto permite que la familia de productos de la compañía Coca Cola estén siempre cerca de sus consumidores a través de estas pequeñas empresas familiares que forman parte de su propia comunidad.

Sin embargo, este tipo de formato de Retail está enfrentando una fuerte competencia por parte de los canales modernos. En un principio fueron las tiendas de conveniencia como Oxxo y 7-Eleven quienes comenzaron a crear una importante cantidad de nuevos establecimientos, cada vez más en zonas habitacionales y no solo en avenidas o gasolineras.

###Importar la base de datos

bd <- read.csv("/Users/hugoenrique/Desktop/4to semestre/Semanas Tec/Bootcamp de programación/Datos Arca Continental Original.csv")

###Entender la base de datos

summary(bd)
##        ID              Año        Territorio        Sub.Territorio    
##  Min.   :     1   Min.   :2016   Length:466509      Length:466509     
##  1st Qu.:116628   1st Qu.:2017   Class :character   Class :character  
##  Median :233255   Median :2018   Mode  :character   Mode  :character  
##  Mean   :233255   Mean   :2018                                        
##  3rd Qu.:349882   3rd Qu.:2019                                        
##  Max.   :466509   Max.   :2019                                        
##      CEDI             Cliente             Nombre          Tamaño.Cte.Industria
##  Length:466509      Length:466509      Length:466509      Length:466509       
##  Class :character   Class :character   Class :character   Class :character    
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character    
##                                                                               
##                                                                               
##                                                                               
##  Segmento.Det          Marca           Presentacion          Tamaño         
##  Length:466509      Length:466509      Length:466509      Length:466509     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##  Retornable_NR         Enero             Febrero             Marzo          
##  Length:466509      Length:466509      Length:466509      Length:466509     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##     Abril               Mayo              Junio              Julio          
##  Length:466509      Length:466509      Length:466509      Length:466509     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##     Agosto           Septiembre          Octubre           Noviembre        
##  Length:466509      Length:466509      Length:466509      Length:466509     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##   Diciembre        
##  Length:466509     
##  Class :character  
##  Mode  :character  
##                    
##                    
## 
str(bd)
## 'data.frame':    466509 obs. of  25 variables:
##  $ ID                  : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Año                 : int  2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 ...
##  $ Territorio          : chr  "Guadalajara" "Guadalajara" "Guadalajara" "Guadalajara" ...
##  $ Sub.Territorio      : chr  "Belenes" "Belenes" "Belenes" "Belenes" ...
##  $ CEDI                : chr  "Suc. Belenes" "Suc. Belenes" "Suc. Belenes" "Suc. Belenes" ...
##  $ Cliente             : chr  "77737" "77737" "77737" "77737" ...
##  $ Nombre              : chr  "ABARR" "ABARR" "ABARR" "ABARR" ...
##  $ Tamaño.Cte.Industria: chr  "Extra Grande" "Extra Grande" "Extra Grande" "Extra Grande" ...
##  $ Segmento.Det        : chr  "Agua Mineral" "Agua Purificada" "Agua Purificada" "Agua Saborizada" ...
##  $ Marca               : chr  "Topo Chico A.M." "Ciel Agua Purificada" "Ciel Agua Purificada" "Ciel Exprim" ...
##  $ Presentacion        : chr  "600 ml NR" "1 Ltro. N.R." "1.5 Lts. NR" "600 ml NR" ...
##  $ Tamaño              : chr  "Individual" "Individual" "Individual" "Individual" ...
##  $ Retornable_NR       : chr  "No Retornable" "No Retornable" "No Retornable" "No Retornable" ...
##  $ Enero               : chr  "" "" "" "" ...
##  $ Febrero             : chr  "" "2" "" "" ...
##  $ Marzo               : chr  "" "8" "3" "" ...
##  $ Abril               : chr  "" "4" "6" "" ...
##  $ Mayo                : chr  "" "4" "3" "" ...
##  $ Junio               : chr  "" "2" "3" "" ...
##  $ Julio               : chr  "" "2" "3" "" ...
##  $ Agosto              : chr  "" "2" "3" "" ...
##  $ Septiembre          : chr  "" "2" "3" "" ...
##  $ Octubre             : chr  "" "2" "3" "" ...
##  $ Noviembre           : chr  "" "4" "3" "" ...
##  $ Diciembre           : chr  "1" "2" "3" "1" ...
#Convertir tipos de variables
bd$Cliente <- as.integer(bd$Cliente)
## Warning: NAs introduced by coercion
bd$Enero <- as.integer(bd$Enero)
## Warning: NAs introduced by coercion
bd$Febrero <- as.integer(bd$Febrero)
## Warning: NAs introduced by coercion
bd$Marzo <- as.integer(bd$Marzo)
## Warning: NAs introduced by coercion
bd$Abril <- as.integer(bd$Abril)
## Warning: NAs introduced by coercion
bd$Mayo <- as.integer(bd$Mayo)
## Warning: NAs introduced by coercion
bd$Junio <- as.integer(bd$Junio)
## Warning: NAs introduced by coercion
bd$Julio <- as.integer(bd$Julio)
## Warning: NAs introduced by coercion
bd$Agosto <- as.integer(bd$Agosto)
## Warning: NAs introduced by coercion
bd$Septiembre <- as.integer(bd$Septiembre)
## Warning: NAs introduced by coercion
bd$Octubre <- as.integer(bd$Octubre)
## Warning: NAs introduced by coercion
bd$Noviembre <- as.integer(bd$Noviembre)
## Warning: NAs introduced by coercion
bd$Diciembre <- as.integer(bd$Diciembre)
## Warning: NAs introduced by coercion
#¿Cuántos NA's en la base de datos?
sum(is.na(bd))
## [1] 3149804
#¿Cuántos NA's hay por variable?
sapply(bd, function(x) sum(is.na(x)))
##                   ID                  Año           Territorio 
##                    0                    0                    0 
##       Sub.Territorio                 CEDI              Cliente 
##                    0                    0                    1 
##               Nombre Tamaño.Cte.Industria         Segmento.Det 
##                    0                    0                    0 
##                Marca         Presentacion               Tamaño 
##                    0                    0                    0 
##        Retornable_NR                Enero              Febrero 
##                    0               233552               231286 
##                Marzo                Abril                 Mayo 
##               227507               224186               217073 
##                Junio                Julio               Agosto 
##               215908               223538               220367 
##           Septiembre              Octubre            Noviembre 
##               337402               338483               338546 
##            Diciembre 
##               341955

#Limpiar la base de datos

boxplot(bd$Enero)

boxplot(bd$Diciembre)

mean(bd$Enero, na.rm = TRUE)
## [1] 9.391922
mean(bd$Enero, trim = 10/100, na.rm = TRUE)
## [1] 3.677421
#Gráfica
plot(bd$ID, bd$Enero, main="Ventas")

###Funciones

library("dplyr") #Librería a utilizar
## 
## 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
#Muestra las ventas de Enero a Junio por CEDI
bd1 <- select(bd, CEDI,Enero:Junio)
head(bd1) #Muestra los primeros 6 renglones
##           CEDI Enero Febrero Marzo Abril Mayo Junio
## 1 Suc. Belenes    NA      NA    NA    NA   NA    NA
## 2 Suc. Belenes    NA       2     8     4    4     2
## 3 Suc. Belenes    NA      NA     3     6    3     3
## 4 Suc. Belenes    NA      NA    NA    NA   NA    NA
## 5 Suc. Belenes    NA      NA    NA    NA   NA    NA
## 6 Suc. Belenes    NA      NA     1    NA   NA    NA
#Muestra los movimientos por CEDI y tamaño de tienda grande.
bd2 <- filter(bd, Tamaño.Cte.Industria=="Grande")
head(bd2)
##       ID  Año  Territorio Sub.Territorio         CEDI Cliente Nombre
## 1 374960 2019 Guadalajara        Belenes Suc. Belenes    7657  FROYL
## 2 374961 2019 Guadalajara        Belenes Suc. Belenes    7657  FROYL
## 3 374962 2019 Guadalajara        Belenes Suc. Belenes    7657  FROYL
## 4 374963 2019 Guadalajara        Belenes Suc. Belenes    7657  FROYL
## 5 374964 2019 Guadalajara        Belenes Suc. Belenes    7657  FROYL
## 6 374965 2019 Guadalajara        Belenes Suc. Belenes    7657  FROYL
##   Tamaño.Cte.Industria    Segmento.Det                Marca Presentacion
## 1               Grande    Agua Mineral    Ciel Mineralizada    600 ml NR
## 2               Grande    Agua Mineral      Topo Chico A.M.  1.5 Lts. NR
## 3               Grande    Agua Mineral      Topo Chico A.M.    600 ml NR
## 4               Grande Agua Purificada Ciel Agua Purificada 1 Ltro. N.R.
## 5               Grande Agua Purificada Ciel Agua Purificada  1.5 Lts. NR
## 6               Grande Agua Purificada Ciel Agua Purificada    5 Lts. NR
##       Tamaño Retornable_NR Enero Febrero Marzo Abril Mayo Junio Julio Agosto
## 1 Individual No Retornable     1      NA    NA     1    1    NA    NA     NA
## 2   Familiar No Retornable    NA       2     5     2    2     2    NA      2
## 3 Individual No Retornable     1       3     3     3    4     1     1      3
## 4 Individual No Retornable     8       2    23    13   21     8    15     19
## 5 Individual No Retornable    13      13    25    22   29    13    10     22
## 6   Familiar No Retornable     4       7    14    14   11    11     7     11
##   Septiembre Octubre Noviembre Diciembre
## 1         NA      NA        NA        NA
## 2         NA      NA        NA        NA
## 3         NA      NA        NA        NA
## 4         NA      NA        NA        NA
## 5         NA      NA        NA        NA
## 6         NA      NA        NA        NA
#ORdena la base de datos por Cedi, marca y pòr presentación
bd3 <- arrange(bd, CEDI)
head(bd3)
##       ID  Año  Territorio Sub.Territorio         CEDI Cliente Nombre
## 1 184065 2018  Territorio Sub Territorio         CEDI      NA Nombre
## 2      1 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 3      2 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 4      3 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 5      4 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 6      5 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
##   Tamaño.Cte.Industria    Segmento.Det                Marca   Presentacion
## 1 Tamaño Cte Industria    Segmento Det                Marca   Presentacion
## 2         Extra Grande    Agua Mineral      Topo Chico A.M.      600 ml NR
## 3         Extra Grande Agua Purificada Ciel Agua Purificada   1 Ltro. N.R.
## 4         Extra Grande Agua Purificada Ciel Agua Purificada    1.5 Lts. NR
## 5         Extra Grande Agua Saborizada          Ciel Exprim      600 ml NR
## 6         Extra Grande Agua Saborizada            Ciel Mini 300 ML. NR PET
##       Tamaño Retornable_NR Enero Febrero Marzo Abril Mayo Junio Julio Agosto
## 1     Tamaño Retornable_NR    NA      NA    NA    NA   NA    NA    NA     NA
## 2 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
## 3 Individual No Retornable    NA       2     8     4    4     2     2      2
## 4 Individual No Retornable    NA      NA     3     6    3     3     3      3
## 5 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
## 6 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
##   Septiembre Octubre Noviembre Diciembre
## 1         NA      NA        NA        NA
## 2         NA      NA        NA         1
## 3          2       2         4         2
## 4          3       3         3         3
## 5         NA      NA        NA         1
## 6         NA      NA         0        NA
bd4 <- arrange(bd, Marca)
head(bd4)
##       ID  Año  Territorio Sub.Territorio           CEDI Cliente Nombre
## 1 184080 2018 Guadalajara      Huentitán Suc. Huentitán    2658   DIAZ
## 2 184081 2018 Guadalajara      Huentitán Suc. Huentitán    2658   DIAZ
## 3 184296 2018 Guadalajara      Huentitán Suc. Huentitán    2682  VARGA
## 4 184297 2018 Guadalajara      Huentitán Suc. Huentitán    2682  VARGA
## 5 184410 2018 Guadalajara      Huentitán Suc. Huentitán    2687  MARIA
## 6 184519 2018 Guadalajara      Huentitán Suc. Huentitán    2713  MARIA
##   Tamaño.Cte.Industria    Segmento.Det       Marca    Presentacion     Tamaño
## 1         Extra Grande Bebidas de Soya AdeS Frutal    200 ml Tetra Individual
## 2         Extra Grande Bebidas de Soya AdeS Frutal 946 ml NR Tetra   Familiar
## 3         Extra Grande Bebidas de Soya AdeS Frutal    200 ml Tetra Individual
## 4         Extra Grande Bebidas de Soya AdeS Frutal 946 ml NR Tetra   Familiar
## 5         Extra Grande Bebidas de Soya AdeS Frutal    200 ml Tetra Individual
## 6         Extra Grande Bebidas de Soya AdeS Frutal    200 ml Tetra Individual
##   Retornable_NR Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre
## 1 No Retornable    NA      NA    NA    NA   NA    NA    NA     NA         NA
## 2 No Retornable    NA      NA    NA    NA   NA    NA    NA     NA         NA
## 3 No Retornable    NA      NA    NA    NA   NA    NA    NA     NA         NA
## 4 No Retornable    NA      NA    NA    NA   NA    NA    NA     NA         NA
## 5 No Retornable    NA      NA    NA    NA   NA    NA    NA     NA         NA
## 6 No Retornable    NA      NA    NA    NA   NA    NA    NA     NA         NA
##   Octubre Noviembre Diciembre
## 1      NA         1        NA
## 2      NA        NA         0
## 3      NA         0         0
## 4      NA         2        NA
## 5      NA         0         0
## 6      NA         0        NA
bd5 <- arrange(bd, Presentacion)
head(bd5)
##       ID  Año  Territorio Sub.Territorio            CEDI Cliente Nombre
## 1 262937 2019 Guadalajara     Toluquilla Suc. Toluquilla    3961  MINI 
## 2 263111 2019 Guadalajara     Toluquilla Suc. Toluquilla    4026  ABARR
## 3 263199 2019 Guadalajara     Toluquilla Suc. Toluquilla    4050  MARTI
## 4 263295 2019 Guadalajara     Toluquilla Suc. Toluquilla    4122  ESMER
## 5 263405 2019 Guadalajara     Toluquilla Suc. Toluquilla    4167  MINI 
## 6 263521 2019 Guadalajara     Toluquilla Suc. Toluquilla    4169  CREME
##   Tamaño.Cte.Industria  Segmento.Det     Marca Presentacion   Tamaño
## 1         Extra Grande Colas Regular Coca-Cola  1 Ltro Ret. Familiar
## 2         Extra Grande Colas Regular Coca-Cola  1 Ltro Ret. Familiar
## 3         Extra Grande Colas Regular Coca-Cola  1 Ltro Ret. Familiar
## 4         Extra Grande Colas Regular Coca-Cola  1 Ltro Ret. Familiar
## 5         Extra Grande Colas Regular Coca-Cola  1 Ltro Ret. Familiar
## 6         Extra Grande Colas Regular Coca-Cola  1 Ltro Ret. Familiar
##   Retornable_NR Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre
## 1    Retornable    NA      NA    30   129  222   127   142    186         NA
## 2    Retornable    NA      NA     8    85   53    38    44     44         NA
## 3    Retornable    NA      NA    NA    21  101    97    40     NA         NA
## 4    Retornable    NA      NA    34   104  112    63    89     93         NA
## 5    Retornable    NA      NA    15     4    4    17     6     13         NA
## 6    Retornable    NA      NA    53   159  125   116   120    123         NA
##   Octubre Noviembre Diciembre
## 1      NA        NA        NA
## 2      NA        NA        NA
## 3      NA        NA        NA
## 4      NA        NA        NA
## 5      NA        NA        NA
## 6      NA        NA        NA
#Cambia el nombre del campo SubTerritorio por Sub_Territorio
bd6 <- rename(bd, Sub_Territorio = Sub.Territorio)
head(bd6)
##   ID  Año  Territorio Sub_Territorio         CEDI Cliente Nombre
## 1  1 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 2  2 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 3  3 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 4  4 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 5  5 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 6  6 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
##   Tamaño.Cte.Industria    Segmento.Det                Marca   Presentacion
## 1         Extra Grande    Agua Mineral      Topo Chico A.M.      600 ml NR
## 2         Extra Grande Agua Purificada Ciel Agua Purificada   1 Ltro. N.R.
## 3         Extra Grande Agua Purificada Ciel Agua Purificada    1.5 Lts. NR
## 4         Extra Grande Agua Saborizada          Ciel Exprim      600 ml NR
## 5         Extra Grande Agua Saborizada            Ciel Mini 300 ML. NR PET
## 6         Extra Grande Agua Saborizada      Ciel Saborizada   1 Ltro. N.R.
##       Tamaño Retornable_NR Enero Febrero Marzo Abril Mayo Junio Julio Agosto
## 1 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
## 2 Individual No Retornable    NA       2     8     4    4     2     2      2
## 3 Individual No Retornable    NA      NA     3     6    3     3     3      3
## 4 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
## 5 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
## 6 Individual No Retornable    NA      NA     1    NA   NA    NA    NA     NA
##   Septiembre Octubre Noviembre Diciembre
## 1         NA      NA        NA         1
## 2          2       2         4         2
## 3          3       3         3         3
## 4         NA      NA        NA         1
## 5         NA      NA         0        NA
## 6         NA      NA        NA        NA
#Agrega un campo calculado con las ventas del primer semestre y muestra las ventas del primer semestre por marca.
bd7 <- mutate(bd, VentasSemestreUno = sum(Enero,Febrero, Marzo, Abril, Mayo, Junio, na.rm = TRUE))
head(bd7)
##   ID  Año  Territorio Sub.Territorio         CEDI Cliente Nombre
## 1  1 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 2  2 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 3  3 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 4  4 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 5  5 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
## 6  6 2016 Guadalajara        Belenes Suc. Belenes   77737  ABARR
##   Tamaño.Cte.Industria    Segmento.Det                Marca   Presentacion
## 1         Extra Grande    Agua Mineral      Topo Chico A.M.      600 ml NR
## 2         Extra Grande Agua Purificada Ciel Agua Purificada   1 Ltro. N.R.
## 3         Extra Grande Agua Purificada Ciel Agua Purificada    1.5 Lts. NR
## 4         Extra Grande Agua Saborizada          Ciel Exprim      600 ml NR
## 5         Extra Grande Agua Saborizada            Ciel Mini 300 ML. NR PET
## 6         Extra Grande Agua Saborizada      Ciel Saborizada   1 Ltro. N.R.
##       Tamaño Retornable_NR Enero Febrero Marzo Abril Mayo Junio Julio Agosto
## 1 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
## 2 Individual No Retornable    NA       2     8     4    4     2     2      2
## 3 Individual No Retornable    NA      NA     3     6    3     3     3      3
## 4 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
## 5 Individual No Retornable    NA      NA    NA    NA   NA    NA    NA     NA
## 6 Individual No Retornable    NA      NA     1    NA   NA    NA    NA     NA
##   Septiembre Octubre Noviembre Diciembre VentasSemestreUno
## 1         NA      NA        NA         1          15025169
## 2          2       2         4         2          15025169
## 3          3       3         3         3          15025169
## 4         NA      NA        NA         1          15025169
## 5         NA      NA         0        NA          15025169
## 6         NA      NA        NA        NA          15025169
#Obtén la media de las ventas del primer semestre agrupado por marca, presentación y tamaño
summary(bd7)
##        ID              Año        Territorio        Sub.Territorio    
##  Min.   :     1   Min.   :2016   Length:466509      Length:466509     
##  1st Qu.:116628   1st Qu.:2017   Class :character   Class :character  
##  Median :233255   Median :2018   Mode  :character   Mode  :character  
##  Mean   :233255   Mean   :2018                                        
##  3rd Qu.:349882   3rd Qu.:2019                                        
##  Max.   :466509   Max.   :2019                                        
##                                                                       
##      CEDI              Cliente         Nombre          Tamaño.Cte.Industria
##  Length:466509      Min.   :    3   Length:466509      Length:466509       
##  Class :character   1st Qu.: 2509   Class :character   Class :character    
##  Mode  :character   Median : 5488   Mode  :character   Mode  :character    
##                     Mean   :16768                                          
##                     3rd Qu.: 9267                                          
##                     Max.   :99998                                          
##                     NA's   :1                                              
##  Segmento.Det          Marca           Presentacion          Tamaño         
##  Length:466509      Length:466509      Length:466509      Length:466509     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  Retornable_NR          Enero           Febrero           Marzo       
##  Length:466509      Min.   :-19.00   Min.   :-11.00   Min.   :-32.00  
##  Class :character   1st Qu.:  1.00   1st Qu.:  1.00   1st Qu.:  1.00  
##  Mode  :character   Median :  2.00   Median :  2.00   Median :  3.00  
##                     Mean   :  9.39   Mean   :  9.09   Mean   : 10.54  
##                     3rd Qu.:  6.00   3rd Qu.:  6.00   3rd Qu.:  6.00  
##                     Max.   :999.00   Max.   :986.00   Max.   :986.00  
##                     NA's   :233552   NA's   :231286   NA's   :227507  
##      Abril             Mayo             Junio             Julio       
##  Min.   :-70.00   Min.   :-106.00   Min.   :-211.00   Min.   :-60.00  
##  1st Qu.:  1.00   1st Qu.:   1.00   1st Qu.:   1.00   1st Qu.:  1.00  
##  Median :  3.00   Median :   3.00   Median :   3.00   Median :  2.00  
##  Mean   : 10.62   Mean   :  11.44   Mean   :  10.98   Mean   : 10.72  
##  3rd Qu.:  6.00   3rd Qu.:   7.00   3rd Qu.:   6.00   3rd Qu.:  6.00  
##  Max.   :993.00   Max.   : 991.00   Max.   : 998.00   Max.   :993.00  
##  NA's   :224186   NA's   :217073    NA's   :215908    NA's   :223538  
##      Agosto          Septiembre        Octubre         Noviembre     
##  Min.   :-211.00   Min.   :-527     Min.   :-38.0    Min.   :-25.0   
##  1st Qu.:   1.00   1st Qu.:   1     1st Qu.:  1.0    1st Qu.:  1.0   
##  Median :   3.00   Median :   3     Median :  3.0    Median :  3.0   
##  Mean   :  10.95   Mean   :  12     Mean   : 12.1    Mean   : 11.8   
##  3rd Qu.:   6.00   3rd Qu.:   7     3rd Qu.:  7.0    3rd Qu.:  6.0   
##  Max.   : 999.00   Max.   : 993     Max.   :998.0    Max.   :991.0   
##  NA's   :220367    NA's   :337402   NA's   :338483   NA's   :338546  
##    Diciembre      VentasSemestreUno 
##  Min.   :-28      Min.   :15025169  
##  1st Qu.:  1      1st Qu.:15025169  
##  Median :  3      Median :15025169  
##  Mean   : 13      Mean   :15025169  
##  3rd Qu.:  7      3rd Qu.:15025169  
##  Max.   :997      Max.   :15025169  
##  NA's   :341955

###Conclusiones En este ejercicio detectamos que la base de datos esta bien construida, no tiene valores faltantes más que en los meses donde no hay ventas. Detectamos un reglón con valores de ventas con formato fecha que deberemos eliminar. Se realizaron algunas conversiones de tipos de dato caracter (Texto) a números enteros. Se practicaron algunas funciones de manejo de tablas.

LS0tCnRpdGxlOiAiYXJjYSIKYXV0aG9yOiAiSHVnbyBFbnJpcXVlIEVzcHJvbmNlZGEgQW5heWEgLyBBMDEyODQ4MjciCmRhdGU6ICIyMDIzLTAzLTIxIgpvdXRwdXQ6IAogIGh0bWxfZG9jdW1lbnQ6CiAgICB0b2M6IHRydWUKICAgIHRvY19mbG9hdDogdHJ1ZQogICAgY29kZV9kb3dubG9hZDogdHJ1ZQotLS0KIVtdKC9Vc2Vycy9odWdvZW5yaXF1ZS9EZXNrdG9wLzR0byBzZW1lc3Ry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