rhdata <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/FORM - Recursos Humanos mod.csv")
summary (rhdata)## numero_de_empleado nombre_completo edad genero
## Min. : 1.00 Length:999 Min. :18.00 Length:999
## 1st Qu.: 31.00 Class :character 1st Qu.:26.00 Class :character
## Median : 63.00 Mode :character Median :34.00 Mode :character
## Mean : 75.86 Mean :36.07
## 3rd Qu.:127.00 3rd Qu.:45.00
## Max. :169.00 Max. :73.00
## NA's :886 NA's :886
## fecha_de_alta antiguedad BAJA puesto
## Length:999 Min. : 0.000 Min. :3 Length:999
## Class :character 1st Qu.: 0.000 1st Qu.:3 Class :character
## Mode :character Median : 0.000 Median :3 Mode :character
## Mean : 1.425 Mean :3
## 3rd Qu.: 2.000 3rd Qu.:3
## Max. :12.000 Max. :3
## NA's :886 NA's :986
## departamento mano_de_obra salario_diario colonia
## Length:999 Length:999 Min. :144.4 Length:999
## Class :character Class :character 1st Qu.:176.7 Class :character
## Mode :character Mode :character Median :180.7 Mode :character
## Mean :181.4
## 3rd Qu.:180.7
## Max. :441.4
## NA's :886
## municipio
## Length:999
## Class :character
## Mode :character
##
##
##
##
# install.packages("tidyverse")
library(tidyverse)
# install.packages("janitor")
library(janitor)–> Eliminar columnas: Se realizó esta técnica debido a que se necesitaba crear una nueva base de datos con unicamente las columnas relevantes, por lo tanto se decidió eliminar las que no brindaban mucha información al reto.
rhdata <- subset (rhdata,select = -c(BAJA, numero_de_empleado, fecha_de_alta, departamento ))
summary(rhdata)## nombre_completo edad genero antiguedad
## Length:999 Min. :18.00 Length:999 Min. : 0.000
## Class :character 1st Qu.:26.00 Class :character 1st Qu.: 0.000
## Mode :character Median :34.00 Mode :character Median : 0.000
## Mean :36.07 Mean : 1.425
## 3rd Qu.:45.00 3rd Qu.: 2.000
## Max. :73.00 Max. :12.000
## NA's :886 NA's :886
## puesto mano_de_obra salario_diario colonia
## Length:999 Length:999 Min. :144.4 Length:999
## Class :character Class :character 1st Qu.:176.7 Class :character
## Mode :character Mode :character Median :180.7 Mode :character
## Mean :181.4
## 3rd Qu.:180.7
## Max. :441.4
## NA's :886
## municipio
## Length:999
## Class :character
## Mode :character
##
##
##
##
–> Para la segunda técnica empleada, se deciden eliminar los registros sin valor encontrados en la base de datos actualizada. Por lo tanto, primero se necesita buscar los datos faltantes en la base de datos, luego identificarlos en las variables para despues eliminarlos, pues una celda sin datos es irrelevante en la investigación.
¿Cuántos NA tengo en la base de datos?
sum(is.na(rhdata))## [1] 2658
¿Cuántos NA tengo por variable?
sapply(rhdata, function(x) sum (is.na(x)))## nombre_completo edad genero antiguedad puesto
## 0 886 0 886 0
## mano_de_obra salario_diario colonia municipio
## 0 886 0 0
Borrar todos los registros NA de una tabla los N/As en esta sección son registros enteros sin valor
rhdata <- na.omit(rhdata)
summary(rhdata)## nombre_completo edad genero antiguedad
## Length:113 Min. :18.00 Length:113 Min. : 0.000
## Class :character 1st Qu.:26.00 Class :character 1st Qu.: 0.000
## Mode :character Median :34.00 Mode :character Median : 0.000
## Mean :36.07 Mean : 1.425
## 3rd Qu.:45.00 3rd Qu.: 2.000
## Max. :73.00 Max. :12.000
## puesto mano_de_obra salario_diario colonia
## Length:113 Length:113 Min. :144.4 Length:113
## Class :character Class :character 1st Qu.:176.7 Class :character
## Mode :character Mode :character Median :180.7 Mode :character
## Mean :181.4
## 3rd Qu.:180.7
## Max. :441.4
## municipio
## Length:113
## Class :character
## Mode :character
##
##
##
sum(is.na(rhdata))## [1] 0
–> Esta técnica se uso pues todos los valores en la base de datos
deben ser factores para las variables cualitativas y enteros para
variables cuantitativas para poder ser utilizados en las
visualizaciones.
Las variables “character” se cambian a “factor”
rhdata$genero<-as.factor(rhdata$genero)
rhdata$puesto<-as.factor(rhdata$puesto)
rhdata$nombre_completo<-as.factor(rhdata$nombre_completo)
rhdata$mano_de_obra<-as.factor(rhdata$mano_de_obra)
rhdata$colonia<-as.factor(rhdata$colonia)
rhdata$municipio<-as.factor(rhdata$municipio)Las variables cuantitativas se cambian a entero
rhdata$edad <- as.integer(rhdata$edad)
rhdata$antiguedad <- as.integer(rhdata$antiguedad)
rhdata$salario_diario <- as.integer(rhdata$salario_diario)Instalas librerias y entender la base de datos
library(psych)
describe(rhdata)## vars n mean sd median trimmed mad min max range skew
## nombre_completo* 1 113 57.00 32.76 57 57.00 41.51 1 113 112 0.00
## edad 2 113 36.07 12.85 34 35.22 13.34 18 73 55 0.54
## genero* 3 113 1.46 0.50 1 1.45 0.00 1 2 1 0.16
## antiguedad 4 113 1.42 2.52 0 0.81 0.00 0 12 12 2.37
## puesto* 5 113 8.49 8.07 4 7.10 0.00 1 29 28 1.41
## mano_de_obra* 6 113 1.33 0.47 1 1.29 0.00 1 2 1 0.73
## salario_diario 7 113 180.73 34.67 180 176.35 0.00 144 441 297 4.83
## colonia* 8 113 39.42 19.75 47 40.07 19.27 1 73 72 -0.38
## municipio* 9 113 2.58 2.39 1 2.14 0.00 1 9 8 1.19
## kurtosis se
## nombre_completo* -1.23 3.08
## edad -0.61 1.21
## genero* -1.99 0.05
## antiguedad 5.51 0.24
## puesto* 0.44 0.76
## mano_de_obra* -1.49 0.04
## salario_diario 29.83 3.26
## colonia* -0.99 1.86
## municipio* 0.02 0.22
str(rhdata)## 'data.frame': 113 obs. of 9 variables:
## $ nombre_completo: Factor w/ 113 levels "ADELAIDA MENDOZA NAVARRO",..: 92 78 55 71 111 42 11 96 43 110 ...
## $ edad : int 67 43 73 32 57 38 55 26 27 37 ...
## $ genero : Factor w/ 2 levels "FEMENINO","MASCULINO": 2 1 2 1 1 2 1 2 2 1 ...
## $ antiguedad : int 12 11 11 9 8 8 7 6 5 5 ...
## $ puesto : Factor w/ 29 levels "AY. GENERAL",..: 27 28 10 29 29 8 7 4 3 7 ...
## $ mano_de_obra : Factor w/ 2 levels "Directo","Indirecto": 2 2 2 2 2 2 1 1 2 1 ...
## $ salario_diario : int 176 176 176 337 441 176 260 240 176 152 ...
## $ colonia : Factor w/ 73 levels "ALAMOS DEL PARQUE",..: 64 61 69 51 56 18 1 52 14 5 ...
## $ municipio : Factor w/ 9 levels "APODACA","CAÑADA BLANCA",..: 9 1 1 1 1 8 1 1 8 9 ...
## - attr(*, "na.action")= 'omit' Named int [1:886] 114 115 116 117 118 119 120 121 122 123 ...
## ..- attr(*, "names")= chr [1:886] "114" "115" "116" "117" ...
La base de datos de Recursos Humanos: Colaboradores cuenta con 113 observaciones y 9 variables.
Variable<-c("`Nombre`","`Edad`","`Genero`","`Antiguedad`","`Puesto`","`Mano de obra`","`Salario Diario`","`Colonia`","`Municipio`")
Type<-c("cualitativa (nominal)", "cuantitativa (discreta)", "cualitativa (nominal)", "cuantitativa (discreta)", "cualitativa (nominal)", "cualitativa (nominal)", "cuantitativa (continua)", "cualitativa (nominal)", "cualitativa (nominal)")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
Nombre |
cualitativa (nominal) |
Edad |
cuantitativa (discreta) |
Genero |
cualitativa (nominal) |
Antiguedad |
cuantitativa (discreta) |
Puesto |
cualitativa (nominal) |
Mano de obra |
cualitativa (nominal) |
Salario Diario |
cuantitativa (continua) |
Colonia |
cualitativa (nominal) |
Municipio |
cualitativa (nominal) |
Variable<-c("`nombre_completo`","`edad`","`genero`","`antiguedad`","`puesto`","`mano_de_obra`","`salario_diario`","`colonia`","`municipio`")
Tipo_medicion <- c("N/A", "años", "N/A", "años", "N/A", "N/A", "MXN PESO", "N/A", "N/A")
table<-data.frame(Variable,Tipo_medicion)
knitr::kable(table)| Variable | Tipo_medicion |
|---|---|
nombre_completo |
N/A |
edad |
años |
genero |
N/A |
antiguedad |
años |
puesto |
N/A |
mano_de_obra |
N/A |
salario_diario |
MXN PESO |
colonia |
N/A |
municipio |
N/A |
Valor que se obtiene al sumar todos los datos y dividirlos entre la cantidad total de datos
media_rhdata <- mean(rhdata$salario_diario)
media_rhdata## [1] 180.7345
Valor que ocupa el lugar central de todos los datos cuando estos estan ordenados de menor a mayor.
mediana_rhdata<- median(rhdata$salario_diario)
mediana_rhdata ## [1] 180
Valor que aparece con mayor frecuencia en un conjunto de datos.
mode <- function (x) {
ux <- unique(x)
ux [which.max(tabulate(match(x,ux)))]
}
mode_rhdata <- mode(rhdata$salario_diario)
mode_rhdata## [1] 180
Relacion entre la media, mediana y moda
Si la media = mediana = moda, los datos tienen una DISTRIBUCION
SIMETRICA.
Si la media < mediana < moda, los datos tienen SESGO
NEGATIVO.
Si la moda < mediana < media, los datos tienen SESGO
POSITIVO.
hist(rhdata$salario_diario)Intervalo o diferencia entre el valor maximo y el minimo de un conjunto de datos
rango_rhdata <- max(rhdata$salario_diario) - min (rhdata$salario_diario)
rango_rhdata ## [1] 297
r<- range(rhdata$salario_diario)
r ## [1] 144 441
varianza_rhdata <- var(rhdata$salario_diario)
varianza_rhdata## [1] 1202.072
Raíz cuadrada de la varianza
desviacion_estandar_rhdata <- sqrt(varianza_rhdata)
desviacion_estandar_rhdata ## [1] 34.67091
summary(rhdata)## nombre_completo edad genero
## ADELAIDA MENDOZA NAVARRO : 1 Min. :18.00 FEMENINO :61
## ADRIANA BADILLO LOZANO : 1 1st Qu.:26.00 MASCULINO:52
## ADRIANA IRENE ZAPATA GARCIA: 1 Median :34.00
## ADRIANA PADILLO CASTILLO : 1 Mean :36.07
## ALFREDO HERNANDEZ PASCUAL : 1 3rd Qu.:45.00
## ALMA DELIA LARA CAMPOS : 1 Max. :73.00
## (Other) :107
## antiguedad puesto mano_de_obra salario_diario
## Min. : 0.000 AYUDANTE GENERAL:59 Directo :76 Min. :144.0
## 1st Qu.: 0.000 COSTURERA :10 Indirecto:37 1st Qu.:176.0
## Median : 0.000 AY. GENERAL : 7 Median :180.0
## Mean : 1.425 SOLDADOR : 5 Mean :180.7
## 3rd Qu.: 2.000 CHOFER : 4 3rd Qu.:180.0
## Max. :12.000 RESIDENTE : 4 Max. :441.0
## (Other) :24
## colonia municipio
## PUEBLO NUEVO :27 APODACA :72
## CANTORAL : 4 JUAREZ :10
## CAÑADA BLANCA : 3 PESQUERIA: 9
## MISION SAN PABLO : 3 GUADALUPE: 6
## PORTAL DE HUINALA : 3 SALTILLO : 5
## VALLE DE SANTA MARIA: 3 MONTERREY: 4
## (Other) :70 (Other) : 7
plot(rhdata$salario_diario, rhdata$antiguedad,main="Relación de variables", xlab="Salario (MXN PESO)",ylab="Tiempo de antiguedad en la empresa")ggplot(rhdata, aes(x=mano_de_obra, y=salario_diario)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() + #
labs(title = "Relación de Tipo de empleado y Salario",
subtitle = "RH empresa FORM",
caption = "Relación",
x = "Puesto",
y = "Salario")La variable mano de obra representa los dos tipos de empleados que hay en la empresa directos (que forman parte del proceso de la elaboración de los paquetes) e indirectos (quienes ayudan a transportar, y/o administrar los paquetes).
colablimpia<-rhdata
write.csv(colablimpia,file = "RHCOLABLIMPIA.csv", row.names = FALSE)–> Técnicas de limpieza fueron hechas desde excel, siendo estas eliminar columnas y agregar columna de edad utilizando la fecha de nacimiento y la formula de edad brindada por excel.
bajasrh<- read.csv("/Users/ivannagarza/Downloads/RHBAJASLIMPIA1.csv")summary(bajasrh)## nombre edad genero fecha_alta
## Length:237 Min. : 0.00 Length:237 Length:237
## Class :character 1st Qu.:23.00 Class :character Class :character
## Mode :character Median :29.00 Mode :character Mode :character
## Mean :30.52
## 3rd Qu.:37.00
## Max. :61.00
## motivo_baja dias_laborados fecha_baja puesto
## Length:237 Min. : 0.00 Length:237 Length:237
## Class :character 1st Qu.: 9.00 Class :character Class :character
## Mode :character Median : 21.00 Mode :character Mode :character
## Mean : 83.42
## 3rd Qu.: 49.00
## Max. :1966.00
## sal_imss colonia municipio estado
## Min. :144.4 Length:237 Length:237 Length:237
## 1st Qu.:180.7 Class :character Class :character Class :character
## Median :180.7 Mode :character Mode :character Mode :character
## Mean :178.6
## 3rd Qu.:180.7
## Max. :500.0
## estado_civil
## Length:237
## Class :character
## Mode :character
##
##
##
Variable<-c("Nombre", "Edad", "Genero", "Fecha de alta", "Motivo de baja", "Días laborados", "Fecha de baja", "Puesto", "Salario IMSS", "Colonia", "Municipio", "Estado", "Estado Civil")
Type<-c("Cualitativa (Nominal)", "Cuantitativa (Discreta)", "Cualitativa (Nominal)", "Cualitativa (Nominal)", "Cualitativa (Nominal)", "Cuantitativa (Discreta)", "Cualitativa (Nominal)", "Cualitativa (Nominal)", "Cuantitativa (Continuo)", "Cualitativa (Nominal)", "Cualitativa (Nominal)", "Cualitativa (Nominal)", "Cualitativa (Nominal)")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
| Nombre | Cualitativa (Nominal) |
| Edad | Cuantitativa (Discreta) |
| Genero | Cualitativa (Nominal) |
| Fecha de alta | Cualitativa (Nominal) |
| Motivo de baja | Cualitativa (Nominal) |
| Días laborados | Cuantitativa (Discreta) |
| Fecha de baja | Cualitativa (Nominal) |
| Puesto | Cualitativa (Nominal) |
| Salario IMSS | Cuantitativa (Continuo) |
| Colonia | Cualitativa (Nominal) |
| Municipio | Cualitativa (Nominal) |
| Estado | Cualitativa (Nominal) |
| Estado Civil | Cualitativa (Nominal) |
Variable<-c("Nombre", "Edad", "Genero", "Fecha de alta", "Motivo de baja", "Días laborados", "Fecha de baja", "Puesto", "Salario IMSS", "Colonia", "Municipio", "Estado", "Estado Civil")
Type<-c("N/A", "Años", "N/A", "N/A", "N/A", "Días", "N/A", "N/A", "MXN PESO", "N/A", "N/A", "N/A", "N/A")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
| Nombre | N/A |
| Edad | Años |
| Genero | N/A |
| Fecha de alta | N/A |
| Motivo de baja | N/A |
| Días laborados | Días |
| Fecha de baja | N/A |
| Puesto | N/A |
| Salario IMSS | MXN PESO |
| Colonia | N/A |
| Municipio | N/A |
| Estado | N/A |
| Estado Civil | N/A |
str (bajasrh)## 'data.frame': 237 obs. of 13 variables:
## $ nombre : chr "MARIO VALDEZ ORTIZ" "ISABEL BARRIOS MENDEZ" "MARIA ELIZABETH GOMEZ HERNANDEZ" "ALONDRA ABIGAIL ESCARCIA GOMEZ" ...
## $ edad : int 32 36 23 21 29 46 29 31 50 19 ...
## $ genero : chr "MASCULINO" "FEMENINO" "FEMENINO" "FEMENINO" ...
## $ fecha_alta : chr "09/03/20" "09/11/21" "10/11/21" "10/11/21" ...
## $ motivo_baja : chr "RENUNCIA VOLUNTARIA" "RENUNCIA VOLUNTARIA" "RENUNCIA VOLUNTARIA" "RENUNCIA VOLUNTARIA" ...
## $ dias_laborados: int 628 60 59 59 51 37 37 31 18 224 ...
## $ fecha_baja : chr "27/11/21" "08/01/22" "08/01/22" "08/01/22" ...
## $ puesto : chr "DISEÑO" "AYUDANTE GENERAL" "AYUDANTE GENERAL" "AYUDANTE GENERAL" ...
## $ sal_imss : num 500 152 152 152 152 ...
## $ colonia : chr "SAN NICOLAS DE LOS G" "COLINAS DEL AEROPÑUERTO" "PUEBLO NUEVO" "PUEBLO NUEVO" ...
## $ municipio : chr "SAN NICOLAS DE LOS G" "PESQUERIA" "APODACA" "APODACA" ...
## $ estado : chr "NUEVO LEÓN" "NUEVO LEÓN" "NUEVO LEÓN" "NUEVO LEÓN" ...
## $ estado_civil : chr "SOLTERO" "UNIÓN LIBRE" "CASADO" "SOLTERO" ...
La base de datos de Bajas cuenta con 237 observaciones y 13 variables.
Valor que se obtiene al sumar todos los datos y dividirlos entre la cantidad total de datos
media_bajasrh <- mean(bajasrh$dias_laborados)
media_bajasrh## [1] 83.42194
media_bajasrh2 <- mean (bajasrh$sal_imss)
media_bajasrh2## [1] 178.6395
Valor que ocupa el lugar central de todos los datos cuando estos estan ordenados de menor a mayor.
mediana_bajasrh<- median(bajasrh$sal_imss)
mediana_bajasrh ## [1] 180.68
mediana_bajasrh2<- median(bajasrh$dias_laborados)
mediana_bajasrh2 ## [1] 21
Valor que aparece con mayor frecuencia en un conjunto de datos.
mode <- function (x) {
ux <- unique(x)
ux [which.max(tabulate(match(x,ux)))]
}
mode_bajasrh <- mode(bajasrh$dias_laborados)
mode_bajasrh## [1] 15
mode_bajasrh2 <- mode(bajasrh$sal_imss)
mode_bajasrh2## [1] 180.68
Relacion entre la media, mediana y moda
Si la media = mediana = moda, los datos tienen una DISTRIBUCION
SIMETRICA.
Si la media < mediana < moda, los datos tienen SESGO
NEGATIVO.
Si la moda < mediana < media, los datos tienen SESGO
POSITIVO.
hist(bajasrh$sal_imss)hist(bajasrh$dias_laborados)varianza_bajasrh <- var(bajasrh$sal_imss)
varianza_bajasrh## [1] 647.251
varianza_bajasrh2 <- var(bajasrh$dias_laborados)
varianza_bajasrh2## [1] 51473.74
Raíz cuadrada de la varianza
desviacion_estandar_bajasrh <- sqrt(varianza_bajasrh)
desviacion_estandar_bajasrh ## [1] 25.44113
desviacion_estandar_bajasrh2 <- sqrt(varianza_bajasrh2)
desviacion_estandar_bajasrh2## [1] 226.8782
ggplot(bajasrh, aes(x=dias_laborados, y=motivo_baja)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() +
labs(title = "Relación de Tipo de días laborados y motivo de baja",
subtitle = "RH empresa FORM",
caption = "Relación",
x = "Días",
y = "Motivo de baja")ggplot(bajasrh, aes(x=edad, y=motivo_baja)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() +
labs(title = "Rango de edades mayoritario en bajas",
subtitle = "RH empresa FORM",
caption = "Relación",
x = "Años",
y = "Motivo de baja")bajaslimpia<-bajasrh
write.csv(bajaslimpia,file = "RHBAJASLIMPIA.csv", row.names = FALSE)del_plan <- read.csv("/Users/ivannagarza/Downloads/DP_1.csv")–> Esto fue necesario primeramente para poder tener mejor manejo de las unidades de produccion mensuales ya que originalmente en la base de datos estas eran registradas diariamente lo cual tornaria el analisis mil veces mas tedioso. Despues de eso con la funcion de pivot_longer se logro cambiar de posicion para que asi se pudieran ver las variables de una manera mas optima para poder realizar los siguienres analisis.
del_plan <- clean_names(del_plan)
del_plan<-del_plan %>% dplyr::rename(jun_21=junio,
jul_21=julio,
ago_21=agosto, sep_21=septiembre, oct_21= octubre, nov_21=noviembre, dic_21=diciembre, oct_22=octubre_22)
del_plan<-pivot_longer(del_plan, cols=5:16, names_to = "mes", values_to = "unidades")
del_plan <- dplyr::select(del_plan, -c(5:15))–> De igual manera, fue necesario eliminar columnas no necesarias como ID ODOO, Proyecto e ITEM ya que a pesar de que son importantes generalmente, en este momento exacto no iban a ser de mucha ayuda ya que lo que nos interesa se encuentra en otras columnas.
del_plan <- dplyr::select(del_plan, -c(2:4))–> Al observar la base de datos no se encuentran NA ni valores atipicos, unicamente eliminaremos los registros que tienen 0 unidades programadas.
del_plan <- filter(del_plan, unidades>0)
sum(is.na(del_plan))## [1] 0
str(del_plan)## tibble [733 × 3] (S3: tbl_df/tbl/data.frame)
## $ cliente_planta: chr [1:733] "STB3" "STB3" "STB3" "STB3" ...
## $ mes : chr [1:733] "jul_21" "ago_21" "oct_21" "dic_21" ...
## $ unidades : int [1:733] 140 530 200 150 230 500 184 125 55 55 ...
summary (del_plan)## cliente_planta mes unidades
## Length:733 Length:733 Min. : 1.0
## Class :character Class :character 1st Qu.: 30.0
## Mode :character Mode :character Median : 76.0
## Mean : 406.4
## 3rd Qu.: 300.0
## Max. :17665.0
Podemos observar que la base de datos cuenta con 231 observaciones y 27 variables, después de la limpia que se aplico.
Variable<-c("Cliente", "Proyecto", "ID", "Item", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")
Type<-c("Cualitativa", "Cualitativa", "Cualitativa", "Cualitativa", "Cuantitativa", "Cuantitativa", "Cuantitativa", "Cuantitativa", "Cuantitativa", "Cuantitativa","Cuantitativa" )
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
| Cliente | Cualitativa |
| Proyecto | Cualitativa |
| ID | Cualitativa |
| Item | Cualitativa |
| Junio | Cuantitativa |
| Julio | Cuantitativa |
| Agosto | Cuantitativa |
| Septiembre | Cuantitativa |
| Octubre | Cuantitativa |
| Noviembre | Cuantitativa |
| Diciembre | Cuantitativa |
Variable<-c("Cliente", "Proyecto", "ID", "Item", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")
Type<-c("N/A", "N/A", "N/A", "N/A", "unidades programadas", "unidades programadas", "unidades programadas", "unidades programadas", "unidades programadas", "unidades programadas", "unidades programadas")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
| Cliente | N/A |
| Proyecto | N/A |
| ID | N/A |
| Item | N/A |
| Junio | unidades programadas |
| Julio | unidades programadas |
| Agosto | unidades programadas |
| Septiembre | unidades programadas |
| Octubre | unidades programadas |
| Noviembre | unidades programadas |
| Diciembre | unidades programadas |
library(dplyr)
str(del_plan)## tibble [733 × 3] (S3: tbl_df/tbl/data.frame)
## $ cliente_planta: chr [1:733] "STB3" "STB3" "STB3" "STB3" ...
## $ mes : chr [1:733] "jul_21" "ago_21" "oct_21" "dic_21" ...
## $ unidades : int [1:733] 140 530 200 150 230 500 184 125 55 55 ...
del_plan$cliente_planta<-as.factor(del_plan$cliente_planta)
del_plan$unidades<-as.numeric(del_plan$unidades)
del_plan2<-aggregate(unidades~cliente_planta, data = del_plan,sum)%>% arrange(desc(unidades))
del_plan3<-filter(del_plan2, unidades>4000)
ggplot(del_plan3, aes(x=reorder(cliente_planta,unidades), y=unidades)) +
geom_bar(stat="identity")+
coord_flip()del_plan2$unidades<-as.numeric(del_plan2$unidades)
ggplot(del_plan, aes(x=cliente_planta, y=unidades, fill=cliente_planta)) +
geom_boxplot() boxplot(del_plan3$cliente_planta,del_plan3$unidades)class(del_plan2$unidades)## [1] "numeric"
del_plan4<-aggregate(unidades~cliente_planta+mes, data = del_plan,sum)%>% arrange(desc(unidades))
del_plan5<-filter(del_plan4, cliente_planta=="HELLA" & cliente_planta=="TRMX" & cliente_planta=="VARROC" & cliente_planta=="DENSO")
ggplot(del_plan,aes(x=mes, y=unidades,color=cliente_planta))+
geom_line()+
labs(x="Fecha",y="Delay in Minutes", color="Legend")+
ggtitle("Delays in Performance by Client")delplanlimpia<-del_plan
write.csv(delplanlimpia,file = "DEL.PLANLIMPIA.csv", row.names = FALSE)bd_totaldiferencias<-read.csv ("/Users/ivannagarza/Downloads/FORM - Delivery Performance BD.csv")
bd_totalmes<-read.csv ("/Users/ivannagarza/Downloads/bdclientes DP.csv")library (tidyverse)
library (janitor)
library (dplyr)
library (ggplot2)
library (Hmisc)summary (bd_totaldiferencias)## X PRINTEL MAHLE MAGNA
## Length:997 Min. :0.0000 Min. :-11.650 Min. :0
## Class :character 1st Qu.:0.0000 1st Qu.: 1.800 1st Qu.:0
## Mode :character Median :0.0000 Median : 3.000 Median :0
## Mean :0.4418 Mean : 2.364 Mean :0
## 3rd Qu.:1.0000 3rd Qu.: 3.150 3rd Qu.:0
## Max. :4.4000 Max. : 20.000 Max. :0
## NA's :698 NA's :698 NA's :698
## VARROC X.1 X.2 X.3 X.4
## Min. :0 Mode:logical Mode:logical Mode:logical Mode:logical
## 1st Qu.:0 NA's:997 NA's:997 NA's:997 NA's:997
## Median :0
## Mean :0
## 3rd Qu.:0
## Max. :0
## NA's :698
## X.5 X.6 X.7 X.8 X.9
## Mode:logical Mode:logical Mode:logical Mode:logical Mode:logical
## NA's:997 NA's:997 NA's:997 NA's:997 NA's:997
##
##
##
##
##
## X.10 X.11 X.12 X.13 X.14
## Mode:logical Mode:logical Mode:logical Mode:logical Mode:logical
## NA's:997 NA's:997 NA's:997 NA's:997 NA's:997
##
##
##
##
##
## X.15 X.16 X.17 X.18 X.19
## Mode:logical Mode:logical Mode:logical Mode:logical Mode:logical
## NA's:997 NA's:997 NA's:997 NA's:997 NA's:997
##
##
##
##
##
## X.20 X.21
## Mode:logical Mode:logical
## NA's:997 NA's:997
##
##
##
##
##
summary(bd_totalmes)## X PRINTEL MAHLE MAGNA VARROC
## Length:999 Min. : 0.00 Min. :15.70 Min. :0 Min. :0
## Class :character 1st Qu.: 0.00 1st Qu.:46.27 1st Qu.:0 1st Qu.:0
## Mode :character Median : 4.90 Median :60.10 Median :0 Median :0
## Mean :10.16 Mean :54.13 Mean :0 Mean :0
## 3rd Qu.:18.41 3rd Qu.:66.44 3rd Qu.:0 3rd Qu.:0
## Max. :31.21 Max. :71.25 Max. :0 Max. :0
## NA's :986 NA's :986 NA's :986 NA's :986
BASE DE DATOS 1 ### Técnica 1. Remover columna irrelevante
–> Eliminar columnas: Se realizó esta técnica debido a que al momento de entender la base de datos se identificaron columnas sin valor y sin relevancia al objetivo.
bd_totaldiferencias <- subset (bd_totaldiferencias,select = -c(X.1, X.2, X.3, X.4, X.5, X.6, X.7, X.8, X.9, X.10, X.11, X.12, X.13, X.14, X.15, X.16, X.17, X.18, X.19, X.20, X.21 ))
summary (bd_totaldiferencias)## X PRINTEL MAHLE MAGNA
## Length:997 Min. :0.0000 Min. :-11.650 Min. :0
## Class :character 1st Qu.:0.0000 1st Qu.: 1.800 1st Qu.:0
## Mode :character Median :0.0000 Median : 3.000 Median :0
## Mean :0.4418 Mean : 2.364 Mean :0
## 3rd Qu.:1.0000 3rd Qu.: 3.150 3rd Qu.:0
## Max. :4.4000 Max. : 20.000 Max. :0
## NA's :698 NA's :698 NA's :698
## VARROC
## Min. :0
## 1st Qu.:0
## Median :0
## Mean :0
## 3rd Qu.:0
## Max. :0
## NA's :698
–> Es indispensable borrar o reemplazar los valores los cuales no tienen un valor asignado, es decir los NAs.
sum(is.na(bd_totaldiferencias))## [1] 2792
sapply(bd_totaldiferencias, function(x) sum (is.na(x)))## X PRINTEL MAHLE MAGNA VARROC
## 0 698 698 698 698
–> Al visualizar la base de datos, se obtuvo como resultado que habia filas completas sin ningún valor, por lo tanto se decidió eliminar las filas las cuales no cuentan con valores, para tener un mejor manejo al momento de analizar.
bd_totaldiferencias<-bd_totaldiferencias[-c(300:997),]–> Al igual que anteriormente, para poder visualizar e interactuar con diversas variables estas tienen que estar en su formato correcto.
bd_totaldiferencias$PRINTEL<-as.integer(bd_totaldiferencias$PRINTEL)
bd_totaldiferencias$MAHLE<-as.integer(bd_totaldiferencias$MAHLE)
bd_totaldiferencias$MAGNA<-as.integer(bd_totaldiferencias$MAGNA)
bd_totaldiferencias$VARROC<-as.integer(bd_totaldiferencias$VARROC) BASE DE DATOS 2 ### Técnica 1. Eliminar NA’s
bd_totalmes<-bd_totalmes[-c(14:999),]bd_totalmes$PRINTEL<-as.integer(bd_totalmes$PRINTEL)
bd_totalmes$MAHLE<-as.integer(bd_totalmes$MAHLE)
bd_totalmes$MAGNA<-as.integer(bd_totalmes$MAGNA)
bd_totalmes$VARROC<-as.integer(bd_totalmes$VARROC) str (bd_totaldiferencias)## 'data.frame': 299 obs. of 5 variables:
## $ X : chr "July 22 th " "July 25th " "July 26th " "July 27th " ...
## $ PRINTEL: int 0 1 1 0 0 1 1 1 0 1 ...
## $ MAHLE : int 2 2 2 2 2 2 2 3 3 3 ...
## $ MAGNA : int 0 0 0 0 0 0 0 0 0 0 ...
## $ VARROC : int 0 0 0 0 0 0 0 0 0 0 ...
str (bd_totalmes)## 'data.frame': 13 obs. of 5 variables:
## $ X : chr "jul-21" "ago-21" "sep-21" "oct-21" ...
## $ PRINTEL: int 4 27 8 0 10 18 28 31 0 0 ...
## $ MAHLE : int 15 67 56 67 60 46 66 71 63 50 ...
## $ MAGNA : int 0 0 0 0 0 0 0 0 0 0 ...
## $ VARROC : int 0 0 0 0 0 0 0 0 0 0 ...
summary(bd_totaldiferencias)## X PRINTEL MAHLE MAGNA VARROC
## Length:299 Min. :0.0000 Min. :-11.00 Min. :0 Min. :0
## Class :character 1st Qu.:0.0000 1st Qu.: 1.00 1st Qu.:0 1st Qu.:0
## Mode :character Median :0.0000 Median : 3.00 Median :0 Median :0
## Mean :0.3679 Mean : 2.11 Mean :0 Mean :0
## 3rd Qu.:1.0000 3rd Qu.: 3.00 3rd Qu.:0 3rd Qu.:0
## Max. :4.0000 Max. : 20.00 Max. :0 Max. :0
summary(bd_totalmes)## X PRINTEL MAHLE MAGNA VARROC
## Length:13 Min. : 0.000 Min. :15.00 Min. :0 Min. :0
## Class :character 1st Qu.: 0.000 1st Qu.:46.00 1st Qu.:0 1st Qu.:0
## Mode :character Median : 4.000 Median :60.00 Median :0 Median :0
## Mean : 9.769 Mean :53.62 Mean :0 Mean :0
## 3rd Qu.:18.000 3rd Qu.:66.00 3rd Qu.:0 3rd Qu.:0
## Max. :31.000 Max. :71.00 Max. :0 Max. :0
La base de datos Total diferenicas cuenta con 299 observaciones y 5 variables. La base de datos Total mensual cuenta con 13 observaciones y 5 variables.
Variable<-c("Fecha")
Type<-c("Cualitativa (Ordinal)")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
| Fecha | Cualitativa (Ordinal) |
Variable<-c("PRINTEL", "MAHLE", "MAGNA", "VARROC")
Type<-c("Horas", "Horas", "Horas", "Horas")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
| PRINTEL | Horas |
| MAHLE | Horas |
| MAGNA | Horas |
| VARROC | Horas |
str(bd_totaldiferencias)## 'data.frame': 299 obs. of 5 variables:
## $ X : chr "July 22 th " "July 25th " "July 26th " "July 27th " ...
## $ PRINTEL: int 0 1 1 0 0 1 1 1 0 1 ...
## $ MAHLE : int 2 2 2 2 2 2 2 3 3 3 ...
## $ MAGNA : int 0 0 0 0 0 0 0 0 0 0 ...
## $ VARROC : int 0 0 0 0 0 0 0 0 0 0 ...
str(bd_totalmes)## 'data.frame': 13 obs. of 5 variables:
## $ X : chr "jul-21" "ago-21" "sep-21" "oct-21" ...
## $ PRINTEL: int 4 27 8 0 10 18 28 31 0 0 ...
## $ MAHLE : int 15 67 56 67 60 46 66 71 63 50 ...
## $ MAGNA : int 0 0 0 0 0 0 0 0 0 0 ...
## $ VARROC : int 0 0 0 0 0 0 0 0 0 0 ...
La base de datos 1 (Total diferencias), cuenta con 299 observaciones y 5 variables, mientras que la base de datos 2 (Total mes), cuenta con 13 observaciones y 5 variables.
media_bd <- mean(bd_totaldiferencias$DIFERENCIA)
media_bd## [1] NA
median_bd <- median(bd_totaldiferencias$DIFERENCIA)
median_bd## NULL
mode <- function (x) {
ux <- unique(x)
ux [which.max(tabulate(match(x,ux)))]
}
mode_bd <- mode(bd_totaldiferencias$DIFERENCIA)
mode_bd## NULL
hist(bd_totaldiferencias$MAHLE) hist(bd_totaldiferencias$PRINTEL)media_bdclientes <- mean(bd_totalmes$PRINTEL)
media_bdclientes## [1] 9.769231
median_bdclientes <- median(bd_totalmes$PRINTEL)
median_bdclientes## [1] 4
mode_bdclientes <- mode(bd_totalmes$PRINTEL)
mode_bdclientes## [1] 0
media_bdclientes <- mean(bd_totalmes$MAHLE)
media_bdclientes## [1] 53.61538
median_bdclientes <- median(bd_totalmes$MAHLE)
median_bdclientes## [1] 60
mode_bdclientes <- mode(bd_totalmes$MAHLE)
mode_bdclientes## [1] 67
bdclientes3 <-bd_totalmes
bdclientes3 <- subset (bdclientes3, select = -c (MAGNA,VARROC))
hist(bdclientes3$PRINTEL)hist(bdclientes3$MAHLE)ggplot(bd_totalmes, aes(x=X, y=MAHLE)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() +
labs(title = "Retraso en minutos del cliente MAHLE",
caption = "Empresa FORM",
x = "FECHA",
y = "MAHLE")ggplot(bd_totalmes, aes(x=X, y=PRINTEL)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() +
labs(title = "Retraso en minutos del cliente PRINTEL",
caption = "Empresa FORM",
x = "FECHA",
y = "PRINTEL")totalmeslimpia<-bd_totalmes
write.csv(totalmeslimpia,file = "DEL.PERFLIMPIA1.csv", row.names = FALSE)
totaldiflimpia<-bd_totaldiferencias
write.csv(totaldiflimpia,file = "DEL.PERFLIMPIA2.csv", row.names = FALSE)producciontotal <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/BD Producción csv.csv")str(producciontotal)## 'data.frame': 5410 obs. of 17 variables:
## $ Fecha : chr "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
## $ No. : chr "1" "2" "3" "4" ...
## $ CLIENTE : chr "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
## $ ID.FORM : chr "" "N.A." "CORTE." "ST-026-13892" ...
## $ PRODUCTO : chr "STABOMAT 643920. CAJA IMP. CORTE. AZUL.PC0011. ( 2 Pza/Caja)." "KR55006. CAJA IMP. AZUL. CORTE. ( 1 pieza)." "241B KIT. EXPORT. INSERTO CON INSERTO. CORTE para Troquel." "MOPAR GDE. 754549. CAJA IMP. NEGRA. PC0022. ( PC0043: solo si autoriza Calidad). ( 1 Pieza). CORTE." ...
## $ PIEZAS.PROG. : chr "200" "100" "216" "100" ...
## $ TMO..MIN. : chr "20" "15" "20" "10" ...
## $ HR..FIN : chr "9:20" "9:35" "9:55" "10:05" ...
## $ ESTACION.ARRANQUE : chr "C1" "C1" "C1" "C1" ...
## $ Laminas.procesadas : chr "402" "134" "110" "100" ...
## $ INICIO.SEP.UP : chr "9:05" "10:05" "9:40" "11.2" ...
## $ FIN.INICIO.DE.SEP.UP: chr "9.1" "10:16" "9:43" "11:26" ...
## $ INICIO.de.PROCESO : chr "9:12" "10.17" "9:45" "11:30" ...
## $ FIN.de.PROCESO : chr "10:04" "11:05" "9.57" "11:49" ...
## $ TIEMPO.CALIDAD : chr "1" "1" "1" "1" ...
## $ TIEMPO.MATERIALES : int NA NA NA 7 NA NA NA NA NA NA ...
## $ MERMAS.Maquinas. : chr "" "" "" "" ...
–> Realizar este paso es importante para no tener valores que no se necesitan y asi facilitar el manejo de la base de datos.
producciontotal <- subset (producciontotal,select = -c(No., ID.FORM , PRODUCTO, HR..FIN , ESTACION.ARRANQUE , INICIO.SEP.UP ,FIN.INICIO.DE.SEP.UP , INICIO.de.PROCESO , TIEMPO.MATERIALES , MERMAS.Maquinas. ))
summary (producciontotal)## Fecha CLIENTE PIEZAS.PROG. TMO..MIN.
## Length:5410 Length:5410 Length:5410 Length:5410
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
## Laminas.procesadas FIN.de.PROCESO TIEMPO.CALIDAD
## Length:5410 Length:5410 Length:5410
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
library(tibble)–> Cambiar el formato es indispensable para poder realizar de manera correcta las visualizaciones.
Cambiar a entero las variables cuantitativas
producciontotal$PIEZAS.PROG. <- substr(producciontotal$PIEZAS.PROG., start = 1, stop = 2)
tibble (producciontotal)## # A tibble: 5,410 × 7
## Fecha CLIENTE PIEZAS.PROG. TMO..MIN. Laminas.procesadas FIN.d…¹ TIEMP…²
## <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 15/07/22 STABILUS 1 20 20 402 10:04 1
## 2 15/07/22 STABILUS 1 10 15 134 11:05 1
## 3 15/07/22 STABILUS 1 21 20 110 9.57 1
## 4 15/07/22 STABILUS 1 10 10 100 11:49 1
## 5 15/07/22 YANFENG 20 10 51 12:31 1
## 6 15/07/22 TRMX 20 20 402 2:00 1
## 7 15/07/22 STABILUS 1 10 10 22 2.44 1
## 8 15/07/22 YANFENG 12 10 13 3:00 1
## 9 15/07/22 YANFENG 32 10 33 2:12 1
## 10 15/07/22 YANFENG 50 60 501/501 10:59 2
## # … with 5,400 more rows, and abbreviated variable names ¹FIN.de.PROCESO,
## # ²TIEMPO.CALIDAD
producciontotal$PIEZAS.PROG. <- as.integer(producciontotal$PIEZAS.PROG.)
str(producciontotal) ## 'data.frame': 5410 obs. of 7 variables:
## $ Fecha : chr "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
## $ CLIENTE : chr "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
## $ PIEZAS.PROG. : int 20 10 21 10 20 20 10 12 32 50 ...
## $ TMO..MIN. : chr "20" "15" "20" "10" ...
## $ Laminas.procesadas: chr "402" "134" "110" "100" ...
## $ FIN.de.PROCESO : chr "10:04" "11:05" "9.57" "11:49" ...
## $ TIEMPO.CALIDAD : chr "1" "1" "1" "1" ...
producciontotal$TMO..MIN. <- substr(producciontotal$TMO..MIN., start = 1, stop = 2)
tibble (producciontotal)## # A tibble: 5,410 × 7
## Fecha CLIENTE PIEZAS.PROG. TMO..MIN. Laminas.procesadas FIN.d…¹ TIEMP…²
## <chr> <chr> <int> <chr> <chr> <chr> <chr>
## 1 15/07/22 STABILUS 1 20 20 402 10:04 1
## 2 15/07/22 STABILUS 1 10 15 134 11:05 1
## 3 15/07/22 STABILUS 1 21 20 110 9.57 1
## 4 15/07/22 STABILUS 1 10 10 100 11:49 1
## 5 15/07/22 YANFENG 20 10 51 12:31 1
## 6 15/07/22 TRMX 20 20 402 2:00 1
## 7 15/07/22 STABILUS 1 10 10 22 2.44 1
## 8 15/07/22 YANFENG 12 10 13 3:00 1
## 9 15/07/22 YANFENG 32 10 33 2:12 1
## 10 15/07/22 YANFENG 50 60 501/501 10:59 2
## # … with 5,400 more rows, and abbreviated variable names ¹FIN.de.PROCESO,
## # ²TIEMPO.CALIDAD
producciontotal$TMO..MIN. <- as.integer(producciontotal$TMO..MIN.)
str(producciontotal) ## 'data.frame': 5410 obs. of 7 variables:
## $ Fecha : chr "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
## $ CLIENTE : chr "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
## $ PIEZAS.PROG. : int 20 10 21 10 20 20 10 12 32 50 ...
## $ TMO..MIN. : int 20 15 20 10 10 20 10 10 10 60 ...
## $ Laminas.procesadas: chr "402" "134" "110" "100" ...
## $ FIN.de.PROCESO : chr "10:04" "11:05" "9.57" "11:49" ...
## $ TIEMPO.CALIDAD : chr "1" "1" "1" "1" ...
producciontotal$Laminas.procesadas <- substr(producciontotal$Laminas.procesadas, start = 1, stop = 2)
tibble (producciontotal)## # A tibble: 5,410 × 7
## Fecha CLIENTE PIEZAS.PROG. TMO..MIN. Laminas.procesadas FIN.d…¹ TIEMP…²
## <chr> <chr> <int> <int> <chr> <chr> <chr>
## 1 15/07/22 STABILUS 1 20 20 40 10:04 1
## 2 15/07/22 STABILUS 1 10 15 13 11:05 1
## 3 15/07/22 STABILUS 1 21 20 11 9.57 1
## 4 15/07/22 STABILUS 1 10 10 10 11:49 1
## 5 15/07/22 YANFENG 20 10 51 12:31 1
## 6 15/07/22 TRMX 20 20 40 2:00 1
## 7 15/07/22 STABILUS 1 10 10 22 2.44 1
## 8 15/07/22 YANFENG 12 10 13 3:00 1
## 9 15/07/22 YANFENG 32 10 33 2:12 1
## 10 15/07/22 YANFENG 50 60 50 10:59 2
## # … with 5,400 more rows, and abbreviated variable names ¹FIN.de.PROCESO,
## # ²TIEMPO.CALIDAD
producciontotal$Laminas.procesadas <- as.integer(producciontotal$Laminas.procesadas)
str(producciontotal) ## 'data.frame': 5410 obs. of 7 variables:
## $ Fecha : chr "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
## $ CLIENTE : chr "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
## $ PIEZAS.PROG. : int 20 10 21 10 20 20 10 12 32 50 ...
## $ TMO..MIN. : int 20 15 20 10 10 20 10 10 10 60 ...
## $ Laminas.procesadas: int 40 13 11 10 51 40 22 13 33 50 ...
## $ FIN.de.PROCESO : chr "10:04" "11:05" "9.57" "11:49" ...
## $ TIEMPO.CALIDAD : chr "1" "1" "1" "1" ...
producciontotal$TIEMPO.CALIDAD <- substr(producciontotal$TIEMPO.CALIDAD, start = 1, stop = 2)
tibble (producciontotal)## # A tibble: 5,410 × 7
## Fecha CLIENTE PIEZAS.PROG. TMO..MIN. Laminas.procesadas FIN.d…¹ TIEMP…²
## <chr> <chr> <int> <int> <int> <chr> <chr>
## 1 15/07/22 STABILUS 1 20 20 40 10:04 1
## 2 15/07/22 STABILUS 1 10 15 13 11:05 1
## 3 15/07/22 STABILUS 1 21 20 11 9.57 1
## 4 15/07/22 STABILUS 1 10 10 10 11:49 1
## 5 15/07/22 YANFENG 20 10 51 12:31 1
## 6 15/07/22 TRMX 20 20 40 2:00 1
## 7 15/07/22 STABILUS 1 10 10 22 2.44 1
## 8 15/07/22 YANFENG 12 10 13 3:00 1
## 9 15/07/22 YANFENG 32 10 33 2:12 1
## 10 15/07/22 YANFENG 50 60 50 10:59 2
## # … with 5,400 more rows, and abbreviated variable names ¹FIN.de.PROCESO,
## # ²TIEMPO.CALIDAD
producciontotal$TIEMPO.CALIDAD <- as.integer(producciontotal$TIEMPO.CALIDAD)
str(producciontotal) ## 'data.frame': 5410 obs. of 7 variables:
## $ Fecha : chr "15/07/22" "15/07/22" "15/07/22" "15/07/22" ...
## $ CLIENTE : chr "STABILUS 1" "STABILUS 1" "STABILUS 1" "STABILUS 1" ...
## $ PIEZAS.PROG. : int 20 10 21 10 20 20 10 12 32 50 ...
## $ TMO..MIN. : int 20 15 20 10 10 20 10 10 10 60 ...
## $ Laminas.procesadas: int 40 13 11 10 51 40 22 13 33 50 ...
## $ FIN.de.PROCESO : chr "10:04" "11:05" "9.57" "11:49" ...
## $ TIEMPO.CALIDAD : int 1 1 1 1 1 1 1 1 1 2 ...
Convertir formato de la fecha
producciontotal$Fecha <- as.Date(producciontotal$Fecha, format = "%d/%m/%Y")
tibble(producciontotal)## # A tibble: 5,410 × 7
## Fecha CLIENTE PIEZAS.PROG. TMO..MIN. Laminas.proces…¹ FIN.d…² TIEMP…³
## <date> <chr> <int> <int> <int> <chr> <int>
## 1 0022-07-15 STABILUS 1 20 20 40 10:04 1
## 2 0022-07-15 STABILUS 1 10 15 13 11:05 1
## 3 0022-07-15 STABILUS 1 21 20 11 9.57 1
## 4 0022-07-15 STABILUS 1 10 10 10 11:49 1
## 5 0022-07-15 YANFENG 20 10 51 12:31 1
## 6 0022-07-15 TRMX 20 20 40 2:00 1
## 7 0022-07-15 STABILUS 1 10 10 22 2.44 1
## 8 0022-07-15 YANFENG 12 10 13 3:00 1
## 9 0022-07-15 YANFENG 32 10 33 2:12 1
## 10 0022-07-15 YANFENG 50 60 50 10:59 2
## # … with 5,400 more rows, and abbreviated variable names ¹Laminas.procesadas,
## # ²FIN.de.PROCESO, ³TIEMPO.CALIDAD
Convertir variable “Cliente” para análisis descriptivo
producciontotal$CLIENTE<-as.factor(producciontotal$CLIENTE)
str(producciontotal)## 'data.frame': 5410 obs. of 7 variables:
## $ Fecha : Date, format: "0022-07-15" "0022-07-15" ...
## $ CLIENTE : Factor w/ 12 levels "","DENSO","HANON SYSTEMS",..: 6 6 6 6 12 8 6 12 12 12 ...
## $ PIEZAS.PROG. : int 20 10 21 10 20 20 10 12 32 50 ...
## $ TMO..MIN. : int 20 15 20 10 10 20 10 10 10 60 ...
## $ Laminas.procesadas: int 40 13 11 10 51 40 22 13 33 50 ...
## $ FIN.de.PROCESO : chr "10:04" "11:05" "9.57" "11:49" ...
## $ TIEMPO.CALIDAD : int 1 1 1 1 1 1 1 1 1 2 ...
sum(is.na(producciontotal))## [1] 4283
¿Cuántos NA tengo por variable?
sapply(producciontotal, function(x) sum (is.na(x)))## Fecha CLIENTE PIEZAS.PROG. TMO..MIN.
## 0 1 117 1528
## Laminas.procesadas FIN.de.PROCESO TIEMPO.CALIDAD
## 1227 0 1410
Instalar paquetes y librerias necesarias –> Este paso es necesario debido a que las variables, son variables de suma importancia para el análisis por lo tanto el no tener valores afecta gravemente, siendo las piezas programadas, el tiempo mínimo, laminas procesadas y el tiempo de calidad todas variables cuantitativas, se decidio reemplazar los NA de la base de datos por la mediana de los valores de la variable correspondiente.
library(dplyr)producciontotal<-producciontotal %>% mutate(PIEZAS.PROG.=ifelse(is.na(PIEZAS.PROG.),median(PIEZAS.PROG.,na.rm=T),PIEZAS.PROG.))
producciontotal<-producciontotal %>% mutate(TMO..MIN.=ifelse(is.na(TMO..MIN.),median(TMO..MIN.,na.rm=T),TMO..MIN.))
producciontotal<-producciontotal %>% mutate(laminas_procesadas=ifelse(is.na(Laminas.procesadas),median(Laminas.procesadas,na.rm=T),Laminas.procesadas))
producciontotal<-producciontotal %>% mutate(TIEMPO.CALIDAD=ifelse(is.na(TIEMPO.CALIDAD),median(TIEMPO.CALIDAD,na.rm=T),TIEMPO.CALIDAD))Verificar la suma de NAs
sum(is.na(producciontotal))## [1] 1228
sapply(producciontotal, function(x) sum (is.na(x)))## Fecha CLIENTE PIEZAS.PROG. TMO..MIN.
## 0 1 0 0
## Laminas.procesadas FIN.de.PROCESO TIEMPO.CALIDAD laminas_procesadas
## 1227 0 0 0
producciontotal <- na.omit(producciontotal)
summary(producciontotal) ## Fecha CLIENTE PIEZAS.PROG. TMO..MIN.
## Min. :0022-07-15 STABILUS 1:1354 Min. : 1.0 Min. : 0
## 1st Qu.:0022-08-03 TRMX : 704 1st Qu.:14.0 1st Qu.:15
## Median :0022-08-19 STABILUS 3: 642 Median :20.0 Median :20
## Mean :0022-08-19 YANFENG : 506 Mean :27.8 Mean :22
## 3rd Qu.:0022-09-05 DENSO : 414 3rd Qu.:40.0 3rd Qu.:25
## Max. :0022-09-21 VARROC : 315 Max. :99.0 Max. :90
## (Other) : 247
## Laminas.procesadas FIN.de.PROCESO TIEMPO.CALIDAD laminas_procesadas
## Min. : 0.00 Length:4182 Min. : 0.0000 Min. : 0.00
## 1st Qu.: 0.00 Class :character 1st Qu.: 1.0000 1st Qu.: 0.00
## Median :20.00 Mode :character Median : 1.0000 Median :20.00
## Mean :21.87 Mean : 0.9173 Mean :21.87
## 3rd Qu.:33.00 3rd Qu.: 1.0000 3rd Qu.:33.00
## Max. :98.00 Max. :25.0000 Max. :98.00
##
sum(is.na(producciontotal))## [1] 0
str (producciontotal)## 'data.frame': 4182 obs. of 8 variables:
## $ Fecha : Date, format: "0022-07-15" "0022-07-15" ...
## $ CLIENTE : Factor w/ 12 levels "","DENSO","HANON SYSTEMS",..: 6 6 6 6 12 8 6 12 12 12 ...
## $ PIEZAS.PROG. : int 20 10 21 10 20 20 10 12 32 50 ...
## $ TMO..MIN. : num 20 15 20 10 10 20 10 10 10 60 ...
## $ Laminas.procesadas: int 40 13 11 10 51 40 22 13 33 50 ...
## $ FIN.de.PROCESO : chr "10:04" "11:05" "9.57" "11:49" ...
## $ TIEMPO.CALIDAD : num 1 1 1 1 1 1 1 1 1 2 ...
## $ laminas_procesadas: int 40 13 11 10 51 40 22 13 33 50 ...
## - attr(*, "na.action")= 'omit' Named int [1:1228] 20 22 23 35 36 48 49 66 68 77 ...
## ..- attr(*, "names")= chr [1:1228] "20" "22" "23" "35" ...
La base de datos Producción total cuenta con 4182 observaciones y 8 variables.
Variable<-c("`nombre_completo`","`edad`","`genero`","`antiguedad`","`puesto`","`mano_de_obra`","`salario_diario`","`colonia`","`municipio`")
Type<-c("cualitativa (nominal)", "cuantitativa (discreta)", "cualitativa (nominal)", "cuantitativa (discreta)", "cualitativa (nominal)", "cualitativa (nominal)", "cuantitativa (continua)", "cualitativa (nominal)", "cualitativa (nominal)")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
nombre_completo |
cualitativa (nominal) |
edad |
cuantitativa (discreta) |
genero |
cualitativa (nominal) |
antiguedad |
cuantitativa (discreta) |
puesto |
cualitativa (nominal) |
mano_de_obra |
cualitativa (nominal) |
salario_diario |
cuantitativa (continua) |
colonia |
cualitativa (nominal) |
municipio |
cualitativa (nominal) |
library (psych)
describe(producciontotal$PIEZAS.PROG.)## producciontotal$PIEZAS.PROG.
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 83 0.976 27.8 19.72 10 10
## .25 .50 .75 .90 .95
## 14 20 40 50 69
##
## lowest : 1 2 3 4 5, highest: 91 94 96 98 99
describe(producciontotal$TMO..MIN.)## producciontotal$TMO..MIN.
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 18 0.945 22 11.13 10 10
## .25 .50 .75 .90 .95
## 15 20 25 35 50
##
## lowest : 0 5 10 12 13, highest: 60 70 75 80 90
##
## Value 0 5 10 12 13 15 20 25 30 35 40
## Frequency 19 1 751 8 1 539 1385 916 76 101 130
## Proportion 0.005 0.000 0.180 0.002 0.000 0.129 0.331 0.219 0.018 0.024 0.031
##
## Value 45 50 60 70 75 80 90
## Frequency 11 133 62 15 17 5 12
## Proportion 0.003 0.032 0.015 0.004 0.004 0.001 0.003
describe(producciontotal$Laminas.procesadas)## producciontotal$Laminas.procesadas
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 97 0.975 21.87 23.37 0 0
## .25 .50 .75 .90 .95
## 0 20 33 51 66
##
## lowest : 0 1 2 3 4, highest: 93 95 96 97 98
describe(producciontotal$TIEMPO.CALIDAD)## producciontotal$TIEMPO.CALIDAD
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 17 0.614 0.9173 0.6442 0 0
## .25 .50 .75 .90 .95
## 1 1 1 1 1
##
## lowest : 0 1 2 3 4, highest: 12 17 21 22 25
##
## Value 0 1 2 3 4 5 6 7 8 9 10
## Frequency 965 3012 121 24 8 11 5 2 4 7 11
## Proportion 0.231 0.720 0.029 0.006 0.002 0.003 0.001 0.000 0.001 0.002 0.003
##
## Value 11 12 17 21 22 25
## Frequency 7 1 1 1 1 1
## Proportion 0.002 0.000 0.000 0.000 0.000 0.000
producciontotal2<-producciontotal %>% select(CLIENTE,PIEZAS.PROG.,TIEMPO.CALIDAD) %>% group_by(CLIENTE) %>% summarise(across(everything(),mean,na.rm=TRUE)) %>% arrange(desc(PIEZAS.PROG.))producciontotal3<- producciontotal2[-c(10),]library (ggplot2)
ggplot(producciontotal3, aes(x=reorder(CLIENTE,PIEZAS.PROG.), y=PIEZAS.PROG., fill=(TIEMPO.CALIDAD))) +
geom_bar(stat="identity")+
coord_flip()+
guides(fill=guide_legend(reverse=FALSE))producciontotal4<-producciontotal3 %>% select(CLIENTE,PIEZAS.PROG.) %>% group_by(CLIENTE) %>% summarise(PIEZAS.PROG.=sum(PIEZAS.PROG.)) %>% arrange(desc(PIEZAS.PROG.))
ggplot(producciontotal4, aes(x=reorder(CLIENTE,PIEZAS.PROG.), y=PIEZAS.PROG.)) +
geom_bar(stat="identity")+
coord_flip()En los gráficos anteriores podemos observar como el cliente que más piezas programadas tiene, “YANFENG” se le dedica un tiempo de calidad de 1.1 minuto, siendo casi el tiempo mínimo de dedicación. Mientras que el cliente VL-017-1486 es el cliente el cual tiene casi la mitad de piezas programadas que YANFENG sin embargo al que más tiempo se le dedica. Por lo que se puede inferir que sus piezas pudieran ser de mucho márgen de error.
prodlimpia<-producciontotal
write.csv(prodlimpia,file = "PRODUCCIONLIMPIA.csv", row.names = FALSE)bd <-read.csv("/Users/ivannagarza/Downloads/FORM - Merma limpia2.csv")library(tidyverse)
library(janitor)
library(dplyr)
library(ggplot2)summary(bd)## Fecha ENERO KilosEnero Fecha1
## Length:10 Length:10 Min. :2680 Length:10
## Class :character Class :character 1st Qu.:2912 Class :character
## Mode :character Mode :character Median :3400 Mode :character
## Mean :3640
## 3rd Qu.:4128
## Max. :5080
## NA's :6
## FEBRERO KilosFebrero Fecha2 MARZO
## Length:10 Min. :3410 Length:10 Length:10
## Class :character 1st Qu.:3605 Class :character Class :character
## Mode :character Median :3760 Mode :character Mode :character
## Mean :3805
## 3rd Qu.:3915
## Max. :4380
## NA's :4
## KilosMarzo Fecha3 ABRIL KilosAbril
## Min. :2980 Length:10 Length:10 Min. :2950
## 1st Qu.:3420 Class :character Class :character 1st Qu.:3690
## Median :3905 Mode :character Mode :character Median :3940
## Mean :3745 Mean :3764
## 3rd Qu.:4142 3rd Qu.:4050
## Max. :4200 Max. :4190
## NA's :4 NA's :5
## Fecha4 MAYO KilosMayo Fecha5
## Length:10 Length:10 Min. :3680 Length:10
## Class :character Class :character 1st Qu.:4310 Class :character
## Mode :character Mode :character Median :4510 Mode :character
## Mean :4682
## 3rd Qu.:4770
## Max. :6140
## NA's :5
## JUNIO KilosJunio Fecha6 JULIO
## Length:10 Min. :4260 Length:10 Length:10
## Class :character 1st Qu.:4312 Class :character Class :character
## Mode :character Median :4505 Mode :character Mode :character
## Mean :4570
## 3rd Qu.:4762
## Max. :5010
## NA's :6
## KilosJulio Fecha7 AGOSTO KilosAgosto
## Min. :2130 Length:10 Length:10 Min. :1040
## 1st Qu.:3920 Class :character Class :character 1st Qu.:3140
## Median :3960 Mode :character Mode :character Median :3780
## Mean :3874 Mean :3567
## 3rd Qu.:4130 3rd Qu.:4210
## Max. :5230 Max. :5080
## NA's :5 NA's :1
## Fecha8 SEPTIEMBRE KilosSeptiembre
## Length:10 Length:10 Min. :2830
## Class :character Class :character 1st Qu.:2995
## Mode :character Mode :character Median :3394
## Mean :3396
## 3rd Qu.:3796
## Max. :3967
## NA's :6
str(bd)## 'data.frame': 10 obs. of 27 variables:
## $ Fecha : chr "11/01/22" "11/01/22" "22/01/22" "22/01/22" ...
## $ ENERO : chr "Enero" "Enero" "Enero" "Enero" ...
## $ KilosEnero : int 5080 3810 2990 2680 NA NA NA NA NA NA
## $ Fecha1 : chr "18/02/22" "18/02/22" "18/02/22" "18/02/22" ...
## $ FEBRERO : chr "Febrero" "Febrero" "Febrero" "Febrero" ...
## $ KilosFebrero : int 3650 4380 3870 3590 3410 3930 NA NA NA NA
## $ Fecha2 : chr "03/03/22" "08/03/22" "11/03/22" "16/03/22" ...
## $ MARZO : chr "Marzo" "Marzo" "Marzo" "Marzo" ...
## $ KilosMarzo : int 4000 4190 2980 3290 4200 3810 NA NA NA NA
## $ Fecha3 : chr "04/04/22" "11/04/22" "14/04/22" "21/04/22" ...
## $ ABRIL : chr "Abril" "Abril" "Abril" "Abril" ...
## $ KilosAbril : int 3940 4190 2950 3690 4050 NA NA NA NA NA
## $ Fecha4 : chr "02/05/22" "09/05/22" "14/05/22" "24/05/22" ...
## $ MAYO : chr "Mayo" "Mayo" "Mayo" "Mayo" ...
## $ KilosMayo : int 4310 4770 3680 6140 4510 NA NA NA NA NA
## $ Fecha5 : chr "07/06/22" "15/06/22" "20/06/22" "27/06/22" ...
## $ JUNIO : chr "Junio" "Junio" "Junio" "Junio" ...
## $ KilosJunio : int 4680 4330 5010 4260 NA NA NA NA NA NA
## $ Fecha6 : chr "04/07/22" "11/07/22" "16/07/22" "21/07/22" ...
## $ JULIO : chr "Julio" "Julio" "Julio" "Julio" ...
## $ KilosJulio : int 5230 2130 4130 3920 3960 NA NA NA NA NA
## $ Fecha7 : chr "08/08/22" "10/08/22" "11/08/22" "13/08/22" ...
## $ AGOSTO : chr "Agosto" "Agosto" "Agosto" "Agosto" ...
## $ KilosAgosto : int 3140 4210 3140 3780 4240 4200 5080 1040 3270 NA
## $ Fecha8 : chr "05/09/22" "07/09/22" "15/09/22" "21/09/22" ...
## $ SEPTIEMBRE : chr "Septiembre" "Septiembre" "Septiembre" "Septiembre" ...
## $ KilosSeptiembre: int 3050 2830 3967 3739 NA NA NA NA NA NA
Variable<-c("Fecha","ENERO","KilosEnero","Fecha1","FEBRERO","KilosFebrero","Fecha2","MARZO","KilosMarzo","Fecha3","ABRIL","KilosAbril","Fecha4","MAYO","KilosMayo","Fecha5","JUNIO","KilosJunio","Fecha6","JULIO","KilosJulio","Fecha7","AGOSTO","KilosAgosto","Fecha8","SEPTIEMBRE","KilosSeptiembre")
Type<-c("qualitative (nominal)", "qualitative (ordinal)", "quantitative (discrete)","qualitative (nominal)","qualitative (ordinal)","quantitative (discrete)","qualitative (nominal)","qualitative (ordinal)","quantitative (discrete)","qualitative (nominal)","qualitative (ordinal)","quantitative (discrete)","qualitative (nominal)","qualitative (ordinal)","quantitative (discrete)","qualitative (nominal)","qualitative (ordinal)","quantitative (discrete)","qualitative (nominal)","qualitative (ordinal)","quantitative (discrete)","qualitative (nominal)","qualitative (ordinal)","quantitative (discrete)","qualitative (nominal)","qualitative (ordinal)","quantitative (discrete)")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
| Fecha | qualitative (nominal) |
| ENERO | qualitative (ordinal) |
| KilosEnero | quantitative (discrete) |
| Fecha1 | qualitative (nominal) |
| FEBRERO | qualitative (ordinal) |
| KilosFebrero | quantitative (discrete) |
| Fecha2 | qualitative (nominal) |
| MARZO | qualitative (ordinal) |
| KilosMarzo | quantitative (discrete) |
| Fecha3 | qualitative (nominal) |
| ABRIL | qualitative (ordinal) |
| KilosAbril | quantitative (discrete) |
| Fecha4 | qualitative (nominal) |
| MAYO | qualitative (ordinal) |
| KilosMayo | quantitative (discrete) |
| Fecha5 | qualitative (nominal) |
| JUNIO | qualitative (ordinal) |
| KilosJunio | quantitative (discrete) |
| Fecha6 | qualitative (nominal) |
| JULIO | qualitative (ordinal) |
| KilosJulio | quantitative (discrete) |
| Fecha7 | qualitative (nominal) |
| AGOSTO | qualitative (ordinal) |
| KilosAgosto | quantitative (discrete) |
| Fecha8 | qualitative (nominal) |
| SEPTIEMBRE | qualitative (ordinal) |
| KilosSeptiembre | quantitative (discrete) |
–> Esta técnica se utilizó para terminar con una base de datos con todos los registros asignados a un valor, por lo tanto sustituir y eliminar son acciones indispensables dependiendo la variable con la que se trabaje.
Eliminar NA’s y sustituir con 0’s
sum(is.na(bd))## [1] 42
bd[is.na(bd)]<-0Eliminar duplicados
bd[duplicated(bd), ]## [1] Fecha ENERO KilosEnero Fecha1
## [5] FEBRERO KilosFebrero Fecha2 MARZO
## [9] KilosMarzo Fecha3 ABRIL KilosAbril
## [13] Fecha4 MAYO KilosMayo Fecha5
## [17] JUNIO KilosJunio Fecha6 JULIO
## [21] KilosJulio Fecha7 AGOSTO KilosAgosto
## [25] Fecha8 SEPTIEMBRE KilosSeptiembre
## <0 rows> (or 0-length row.names)
sum(duplicated(bd))## [1] 0
Eliminar negativos con cero
bd1<-bd
bd1[bd1 <0] <-0
summary(bd1)## Fecha ENERO KilosEnero Fecha1
## Length:10 Length:10 Min. : 0 Length:10
## Class :character Class :character 1st Qu.: 0 Class :character
## Mode :character Mode :character Median : 0 Mode :character
## Mean :1456
## 3rd Qu.:2912
## Max. :5080
## FEBRERO KilosFebrero Fecha2 MARZO
## Length:10 Min. : 0 Length:10 Length:10
## Class :character 1st Qu.: 0 Class :character Class :character
## Mode :character Median :3500 Mode :character Mode :character
## Mean :2283
## 3rd Qu.:3815
## Max. :4380
## KilosMarzo Fecha3 ABRIL KilosAbril
## Min. : 0 Length:10 Length:10 Min. : 0
## 1st Qu.: 0 Class :character Class :character 1st Qu.: 0
## Median :3135 Mode :character Mode :character Median :1475
## Mean :2247 Mean :1882
## 3rd Qu.:3952 3rd Qu.:3878
## Max. :4200 Max. :4190
## Fecha4 MAYO KilosMayo Fecha5
## Length:10 Length:10 Min. : 0 Length:10
## Class :character Class :character 1st Qu.: 0 Class :character
## Mode :character Mode :character Median :1840 Mode :character
## Mean :2341
## 3rd Qu.:4460
## Max. :6140
## JUNIO KilosJunio Fecha6 JULIO
## Length:10 Min. : 0 Length:10 Length:10
## Class :character 1st Qu.: 0 Class :character Class :character
## Mode :character Median : 0 Mode :character Mode :character
## Mean :1828
## 3rd Qu.:4312
## Max. :5010
## KilosJulio Fecha7 AGOSTO KilosAgosto
## Min. : 0 Length:10 Length:10 Min. : 0
## 1st Qu.: 0 Class :character Class :character 1st Qu.:3140
## Median :1065 Mode :character Mode :character Median :3525
## Mean :1937 Mean :3210
## 3rd Qu.:3950 3rd Qu.:4208
## Max. :5230 Max. :5080
## Fecha8 SEPTIEMBRE KilosSeptiembre
## Length:10 Length:10 Min. : 0
## Class :character Class :character 1st Qu.: 0
## Mode :character Mode :character Median : 0
## Mean :1359
## 3rd Qu.:2995
## Max. :3967
media_bd5 <- mean(bd$KilosMayo)
media_bd5## [1] 2341
median_bd5 <- median(bd$KilosMayo)
median_bd5## [1] 1840
mode_bd5 <- mode(bd$KilosMayo)
mode_bd5## [1] 0
media_bd8 <- mean(bd$KilosAgosto)
media_bd8## [1] 3210
median_bd8 <- median(bd$KilosAgosto)
median_bd8## [1] 3525
mode_bd8 <- mode(bd$KilosAgosto)
mode_bd8## [1] 3140
Gráfica Frecuencia (Fecha)
bd$Fecha7<- as.Date(bd$Fecha7,format = "%d/%m/%Y")
plot(bd$Fecha7, bd$KilosAgosto)Gráfica de Mayo & Agosto (Mayor cantidad de merma y registros)
ggplot(bd, aes(x= Fecha4, y= KilosMayo)) + geom_bar(stat="identity", fill="blue") + scale_fill_grey() + labs(title = "Kilos de merma Agosto", x = "Fecha")ggplot(bd, aes(x= Fecha7, y= KilosAgosto)) + geom_bar(stat="identity", fill="blue") + scale_fill_grey() + labs(title = "Kilos de merma Agosto", x = "Fecha")mermalimpia<-bd1
write.csv(mermalimpia,file = "MERMALIMPIA.csv", row.names = FALSE)library(forecast)sum(bd$KilosEnero)## [1] 14560
sum(bd$KilosFebrero)## [1] 22830
sum(bd$KilosMarzo)## [1] 22470
sum(bd$KilosAbril)## [1] 18820
sum(bd$KilosMayo)## [1] 23410
sum(bd$KilosJunio)## [1] 18280
sum(bd$KilosJulio)## [1] 19370
sum(bd$KilosAgosto)## [1] 32100
sum(bd$KilosSeptiembre)## [1] 13586
merma <- c(14560,22830,22470,18820,23410,18280,19370,32100,13586)
produccion_st <- ts(data = merma, start = c(2022,1), frequency = 12)
produccion_st## Jan Feb Mar Apr May Jun Jul Aug Sep
## 2022 14560 22830 22470 18820 23410 18280 19370 32100 13586
modelo <- auto.arima(produccion_st)
modelo## Series: produccion_st
## ARIMA(0,0,0) with non-zero mean
##
## Coefficients:
## mean
## 20602.889
## s.e. 1736.893
##
## sigma^2 = 30544665: log likelihood = -89.8
## AIC=183.59 AICc=185.59 BIC=183.99
pronostico <- forecast(modelo, level=c(95), h=3)
pronostico## Point Forecast Lo 95 Hi 95
## Oct 2022 20602.89 9770.711 31435.07
## Nov 2022 20602.89 9770.711 31435.07
## Dec 2022 20602.89 9770.711 31435.07
plot(pronostico)scrapdata <- read.csv ("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/FORM - Scrap.csv")
summary (scrapdata)## Referencia Fecha Hora Producto
## Length:251 Length:251 Length:251 Length:251
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
## Cantidad Unidad.de.medida Ubicación.de.origen Ubicación.de.desecho
## Min. : 0.00 Length:251 Length:251 Length:251
## 1st Qu.: 1.00 Class :character Class :character Class :character
## Median : 2.00 Mode :character Mode :character Mode :character
## Mean : 13.34
## 3rd Qu.: 7.00
## Max. :1674.00
## Estado
## Length:251
## Class :character
## Mode :character
##
##
##
library (psych)
describe (scrapdata)## scrapdata
##
## 9 Variables 251 Observations
## --------------------------------------------------------------------------------
## Referencia
## n missing distinct
## 251 0 251
##
## lowest : agosto 2022 (250) SP/08479 SP/08480 SP/08481 SP/08482
## highest: SP/08727 SP/08728 SP/08729 SP/08730 SP/08731
## --------------------------------------------------------------------------------
## Fecha
## n missing distinct
## 250 1 26
##
## lowest : 01/08/2022 02/08/2022 03/08/2022 04/08/2022 05/08/2022
## highest: 26/08/2022 27/08/2022 29/08/2022 30/08/2022 31/08/2022
## --------------------------------------------------------------------------------
## Hora
## n missing distinct
## 250 1 250
##
## lowest : 08:42:31 08:43:05 08:43:32 08:44:04 08:44:27
## highest: 19:37:50 19:38:15 19:39:13 19:40:41 19:41:36
## --------------------------------------------------------------------------------
## Producto
## n missing distinct
## 250 1 95
##
## lowest : [2065WY AS 30 99 0000 00 000 TAPA - BOX 2064WY] BOX 2064WY [241B EXPORT CAJA] 241B. Export. Caja. [341332 CELDA - U611 & U625] 341332. U611. U625. Celda Troquelada. [341332 CHAROLA - U611 & U625] 341332. U611. U625. Charola Troquelada. [341332 DIVISOR - U611 & U625] 341332. U611. U625. Divisor Troquelado.
## highest: [TMC XXX] Armrest. Caja RSC. [TR11910 CHAROLA C/2 DIV #20 SMOOTH C/32 CAVIDADES] TR11910. U725. DMS. ITB. Charola con ITB. [TR12438 TAPA ICP 539 TAPA 2415-2 EN CPARTÓN SENCILLO CORRUGADO] 18840. CD539. Tapa. [TR12440 TAPA P558] 18842. P558. Tapa. [TR13776 CAJA RSC CK 44 ECT C/ PORTA ETIQUETA] TR13776. Caja con Porta Etiqueta.
## --------------------------------------------------------------------------------
## Cantidad
## n missing distinct Info Mean Gmd .05 .10
## 251 0 34 0.959 13.34 21.82 1 1
## .25 .50 .75 .90 .95
## 1 2 7 16 26
##
## lowest : 0.000 1.000 2.000 2.500 3.000
## highest: 56.000 60.000 80.000 96.000 1674.002
##
## Value 0 5 10 15 20 25 30 35 40 45 50
## Frequency 138 51 29 8 8 4 2 2 1 1 2
## Proportion 0.550 0.203 0.116 0.032 0.032 0.016 0.008 0.008 0.004 0.004 0.008
##
## Value 55 60 80 95 1675
## Frequency 1 1 1 1 1
## Proportion 0.004 0.004 0.004 0.004 0.004
##
## For the frequency table, variable is rounded to the nearest 5
## --------------------------------------------------------------------------------
## Unidad.de.medida
## n missing distinct value
## 250 1 1 Unidad(es)
##
## Value Unidad(es)
## Frequency 250
## Proportion 1
## --------------------------------------------------------------------------------
## Ubicación.de.origen
## n missing distinct
## 250 1 3
##
## Value SAB/Calidad/Entrega de PT SAB/Post-Production
## Frequency 58 13
## Proportion 0.232 0.052
##
## Value SAB/Pre-Production
## Frequency 179
## Proportion 0.716
## --------------------------------------------------------------------------------
## Ubicación.de.desecho
## n missing
## 250 1
## distinct value
## 1 Virtual Locations/Scrapped
##
## Value Virtual Locations/Scrapped
## Frequency 250
## Proportion 1
## --------------------------------------------------------------------------------
## Estado
## n missing distinct value
## 250 1 1 Hecho
##
## Value Hecho
## Frequency 250
## Proportion 1
## --------------------------------------------------------------------------------
str(scrapdata)## 'data.frame': 251 obs. of 9 variables:
## $ Referencia : chr "agosto 2022 (250)" "SP/08731" "SP/08730" "SP/08729" ...
## $ Fecha : chr "" "31/08/2022" "31/08/2022" "31/08/2022" ...
## $ Hora : chr "" "14:55:40" "14:49:25" "13:49:29" ...
## $ Producto : chr "" "[BACKFRAME 60% CUELLO ARMADO] 18805. 60% Backframe. Cuello Armado." "[N61506747 CAJA] N61506747. Kit. Caja." "[N61506729 SEPARADOR] N61506729. Kit. Separador." ...
## $ Cantidad : num 1674 2 1 1 31 ...
## $ Unidad.de.medida : chr "" "Unidad(es)" "Unidad(es)" "Unidad(es)" ...
## $ Ubicación.de.origen : chr "" "SAB/Calidad/Entrega de PT" "SAB/Calidad/Entrega de PT" "SAB/Calidad/Entrega de PT" ...
## $ Ubicación.de.desecho: chr "" "Virtual Locations/Scrapped" "Virtual Locations/Scrapped" "Virtual Locations/Scrapped" ...
## $ Estado : chr "" "Hecho" "Hecho" "Hecho" ...
En la base de datos existen 9 variables y 251 registros
Variable<-c("`Referencia`","`Fecha`","`Hora`","`Producto`","`Cantidad`","`Unidad.de.medida`","`Ubicación.de.origen`","`Ubicación.de.desecho`","`Estado`")
Type<-c("cualitativa (nominal)", "cuantitativa (continua)", "cuantitativa (continua)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)" )
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
Referencia |
cualitativa (nominal) |
Fecha |
cuantitativa (continua) |
Hora |
cuantitativa (continua) |
Producto |
cualitativa (nominal) |
Cantidad |
cualitativa (nominal) |
Unidad.de.medida |
cualitativa (nominal) |
Ubicación.de.origen |
cualitativa (nominal) |
Ubicación.de.desecho |
cualitativa (nominal) |
Estado |
cualitativa (nominal) |
Variable<-c("`Cantidad`")
Type<-c("Unidades")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
Cantidad |
Unidades |
library(tidyverse)–> La técnica 1 fue realizada debido a que para poder realizar trabajos y análisis con la fecha y hora es necesario convertirlos a números enteros y así poder hacer las variables cuantitativas.
Convertir de caracter a fecha
scrapdata$Fecha <- as.Date(scrapdata$Fecha, format = "%d/%m/%Y")
tibble(scrapdata)## # A tibble: 251 × 9
## Referencia Fecha Hora Produ…¹ Canti…² Unida…³ Ubica…⁴ Ubica…⁵ Estado
## <chr> <date> <chr> <chr> <dbl> <chr> <chr> <chr> <chr>
## 1 agosto 2022 … NA "" "" 1674. "" "" "" ""
## 2 SP/08731 2022-08-31 "14:… "[BACK… 2 "Unida… "SAB/C… "Virtu… "Hech…
## 3 SP/08730 2022-08-31 "14:… "[N615… 1 "Unida… "SAB/C… "Virtu… "Hech…
## 4 SP/08729 2022-08-31 "13:… "[N615… 1 "Unida… "SAB/C… "Virtu… "Hech…
## 5 SP/08728 2022-08-31 "09:… "[3413… 31 "Unida… "SAB/P… "Virtu… "Hech…
## 6 SP/08727 2022-08-31 "09:… "[DIVI… 1 "Unida… "SAB/P… "Virtu… "Hech…
## 7 SP/08726 2022-08-31 "09:… "[DIVI… 1 "Unida… "SAB/P… "Virtu… "Hech…
## 8 SP/08725 2022-08-31 "09:… "[CHAR… 1 "Unida… "SAB/P… "Virtu… "Hech…
## 9 SP/08724 2022-08-31 "09:… "[CELD… 9 "Unida… "SAB/P… "Virtu… "Hech…
## 10 SP/08723 2022-08-31 "09:… "[TAPA… 2 "Unida… "SAB/P… "Virtu… "Hech…
## # … with 241 more rows, and abbreviated variable names ¹Producto, ²Cantidad,
## # ³Unidad.de.medida, ⁴Ubicación.de.origen, ⁵Ubicación.de.desecho
Convertir de caracter a entero
scrapdata$Hora <- substr(scrapdata$Hora, start = 1, stop = 2)
tibble (scrapdata)## # A tibble: 251 × 9
## Referencia Fecha Hora Produ…¹ Canti…² Unida…³ Ubica…⁴ Ubica…⁵ Estado
## <chr> <date> <chr> <chr> <dbl> <chr> <chr> <chr> <chr>
## 1 agosto 2022 … NA "" "" 1674. "" "" "" ""
## 2 SP/08731 2022-08-31 "14" "[BACK… 2 "Unida… "SAB/C… "Virtu… "Hech…
## 3 SP/08730 2022-08-31 "14" "[N615… 1 "Unida… "SAB/C… "Virtu… "Hech…
## 4 SP/08729 2022-08-31 "13" "[N615… 1 "Unida… "SAB/C… "Virtu… "Hech…
## 5 SP/08728 2022-08-31 "09" "[3413… 31 "Unida… "SAB/P… "Virtu… "Hech…
## 6 SP/08727 2022-08-31 "09" "[DIVI… 1 "Unida… "SAB/P… "Virtu… "Hech…
## 7 SP/08726 2022-08-31 "09" "[DIVI… 1 "Unida… "SAB/P… "Virtu… "Hech…
## 8 SP/08725 2022-08-31 "09" "[CHAR… 1 "Unida… "SAB/P… "Virtu… "Hech…
## 9 SP/08724 2022-08-31 "09" "[CELD… 9 "Unida… "SAB/P… "Virtu… "Hech…
## 10 SP/08723 2022-08-31 "09" "[TAPA… 2 "Unida… "SAB/P… "Virtu… "Hech…
## # … with 241 more rows, and abbreviated variable names ¹Producto, ²Cantidad,
## # ³Unidad.de.medida, ⁴Ubicación.de.origen, ⁵Ubicación.de.desecho
scrapdata$Hora <- as.integer(scrapdata$Hora)
str(scrapdata)## 'data.frame': 251 obs. of 9 variables:
## $ Referencia : chr "agosto 2022 (250)" "SP/08731" "SP/08730" "SP/08729" ...
## $ Fecha : Date, format: NA "2022-08-31" ...
## $ Hora : int NA 14 14 13 9 9 9 9 9 9 ...
## $ Producto : chr "" "[BACKFRAME 60% CUELLO ARMADO] 18805. 60% Backframe. Cuello Armado." "[N61506747 CAJA] N61506747. Kit. Caja." "[N61506729 SEPARADOR] N61506729. Kit. Separador." ...
## $ Cantidad : num 1674 2 1 1 31 ...
## $ Unidad.de.medida : chr "" "Unidad(es)" "Unidad(es)" "Unidad(es)" ...
## $ Ubicación.de.origen : chr "" "SAB/Calidad/Entrega de PT" "SAB/Calidad/Entrega de PT" "SAB/Calidad/Entrega de PT" ...
## $ Ubicación.de.desecho: chr "" "Virtual Locations/Scrapped" "Virtual Locations/Scrapped" "Virtual Locations/Scrapped" ...
## $ Estado : chr "" "Hecho" "Hecho" "Hecho" ...
–> La técnica 2 fue utilizada para poder eliminar los datos que no son útiles, es decir los registros y variables que no contienen información o son irrelevantes para el análisis.
¿Cuántos NA tengo en la base de datos?
sum(is.na(scrapdata))## [1] 2
¿Cuántos NA tengo por variable?
sapply(scrapdata, function(x) sum (is.na(x)))## Referencia Fecha Hora
## 0 1 1
## Producto Cantidad Unidad.de.medida
## 0 0 0
## Ubicación.de.origen Ubicación.de.desecho Estado
## 0 0 0
Borrar todos los registros NA de una tabla
scrapdata <- na.omit(scrapdata)
summary(scrapdata) ## Referencia Fecha Hora Producto
## Length:250 Min. :2022-08-01 Min. : 8 Length:250
## Class :character 1st Qu.:2022-08-11 1st Qu.: 9 Class :character
## Mode :character Median :2022-08-19 Median :11 Mode :character
## Mean :2022-08-17 Mean :12
## 3rd Qu.:2022-08-25 3rd Qu.:14
## Max. :2022-08-31 Max. :19
## Cantidad Unidad.de.medida Ubicación.de.origen Ubicación.de.desecho
## Min. : 0.000 Length:250 Length:250 Length:250
## 1st Qu.: 1.000 Class :character Class :character Class :character
## Median : 2.000 Mode :character Mode :character Mode :character
## Mean : 6.696
## 3rd Qu.: 7.000
## Max. :96.000
## Estado
## Length:250
## Class :character
## Mode :character
##
##
##
sum(is.na(scrapdata))## [1] 0
Eliminar columnas
scrapdata <- subset (scrapdata,select = -c(Referencia,Unidad.de.medida, Estado))
summary (scrapdata)## Fecha Hora Producto Cantidad
## Min. :2022-08-01 Min. : 8 Length:250 Min. : 0.000
## 1st Qu.:2022-08-11 1st Qu.: 9 Class :character 1st Qu.: 1.000
## Median :2022-08-19 Median :11 Mode :character Median : 2.000
## Mean :2022-08-17 Mean :12 Mean : 6.696
## 3rd Qu.:2022-08-25 3rd Qu.:14 3rd Qu.: 7.000
## Max. :2022-08-31 Max. :19 Max. :96.000
## Ubicación.de.origen Ubicación.de.desecho
## Length:250 Length:250
## Class :character Class :character
## Mode :character Mode :character
##
##
##
Valor que se obtiene al sumar todos los datos y dividirlos entre la cantidad total de datos
media_scrapdata <- mean(scrapdata$Cantidad)
media_scrapdata## [1] 6.696
Valor que ocupa el lugar central de todos los datos cuando estos estan ordenados de menor a mayor.
mediana_scrapdata<- median(scrapdata$Cantidad)
mediana_scrapdata ## [1] 2
Valor que aparece con mayor frecuencia en un conjunto de datos.
mode <- function (x) {
ux <- unique(x)
ux [which.max(tabulate(match(x,ux)))]
}
mode_scrapdata <- mode(scrapdata$Cantidad)
mode_scrapdata## [1] 1
Relacion entre la media, mediana y moda
Si la media = mediana = moda, los datos tienen una DISTRIBUCION
SIMETRICA.
Si la media < mediana < moda, los datos tienen SESGO
NEGATIVO.
Si la moda < mediana < media, los datos tienen SESGO
POSITIVO.
hist(scrapdata$Cantidad)varianza_scrapdata <- var(scrapdata$Cantidad)
varianza_scrapdata## [1] 140.3952
Raíz cuadrada de la varianza
desviacion_estandar_scrapdata <- sqrt(varianza_scrapdata)
desviacion_estandar_scrapdata ## [1] 11.84885
ggplot(scrapdata, aes(x=Fecha, y=Cantidad)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() + # Add bars to the plot
labs(title = "Relación de Fecha y Cantidad", # Add a title
subtitle = "RH empresa FORM", # Add a subtitle
caption = "Relación", # Add a caption
x = "Fecha")scraplimpia<-scrapdata
write.csv(scraplimpia,file = "SCRAPLIMPIA.csv", row.names = FALSE)externamx <- read.csv("/Users/ivannagarza/Downloads/industria_automotriz_mx (1).csv")tabla_estadisticos <- describe(externamx)
tabla_estadisticos## externamx
##
## 11 Variables 5 Observations
## --------------------------------------------------------------------------------
## año
## n missing distinct Info Mean Gmd
## 5 0 5 1 2019 2
##
## lowest : 2017 2018 2019 2020 2021, highest: 2017 2018 2019 2020 2021
##
## Value 2017 2018 2019 2020 2021
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## unidades_exportacion
## n missing distinct Info Mean Gmd
## 5 0 5 1 3096421 444005
##
## lowest : 2681806 2706980 3253859 3388305 3451157
## highest: 2681806 2706980 3253859 3388305 3451157
##
## Value 2681806 2706980 3253859 3388305 3451157
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## unidades_produccion
## n missing distinct Info Mean Gmd
## 5 0 5 1 3546297 537554
##
## lowest : 3028481 3040178 3811068 3918603 3933154
## highest: 3028481 3040178 3811068 3918603 3933154
##
## Value 3028481 3040178 3811068 3918603 3933154
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## unidades_ventas
## n missing distinct Info Mean Gmd
## 5 0 5 1 1248952 316422
##
## lowest : 950063 1014735 1317931 1427086 1534943
## highest: 950063 1014735 1317931 1427086 1534943
##
## Value 950063 1014735 1317931 1427086 1534943
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## empleados_automotriz
## n missing distinct Info Mean Gmd
## 5 0 5 1 833200 35800
##
## lowest : 784000 831000 840000 844000 867000, highest: 784000 831000 840000 844000 867000
##
## Value 784000 831000 840000 844000 867000
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## compensaciones_empleados
## n missing distinct Info Mean Gmd
## 5 0 5 1 542087 42136
##
## lowest : 506716 520113 527878 567228 588498, highest: 506716 520113 527878 567228 588498
##
## Value 506716 520113 527878 567228 588498
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## salario_min
## n missing distinct Info Mean Gmd
## 5 0 5 1 3261 962.2
##
## lowest : 2434.6 2687.6 3123.2 3747.9 4310.0, highest: 2434.6 2687.6 3123.2 3747.9 4310.0
##
## Value 2434.6 2687.6 3123.2 3747.9 4310.0
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## Conf_Consumidor
## n missing distinct Info Mean Gmd
## 5 0 5 1 41.72 4.656
##
## lowest : 36.3155 38.7487 43.7574 44.8654 44.8964
## highest: 36.3155 38.7487 43.7574 44.8654 44.8964
##
## Value 36.3155 38.7487 43.7574 44.8654 44.8964
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## tasa_inflación
## n missing distinct Info Mean Gmd
## 5 0 5 1 4.988 2.536
##
## lowest : 2.83 3.15 4.83 6.77 7.36, highest: 2.83 3.15 4.83 6.77 7.36
##
## Value 2.83 3.15 4.83 6.77 7.36
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## X..Pob.Desocu
## n missing distinct Info Mean Gmd
## 5 0 5 1 3.344 0.424
##
## lowest : 2.91 3.15 3.36 3.51 3.79, highest: 2.91 3.15 3.36 3.51 3.79
##
## Value 2.91 3.15 3.36 3.51 3.79
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
## X..Pob.Ocu
## n missing distinct Info Mean Gmd
## 5 0 5 1 96.66 0.424
##
## lowest : 96.21 96.49 96.64 96.85 97.09, highest: 96.21 96.49 96.64 96.85 97.09
##
## Value 96.21 96.49 96.64 96.85 97.09
## Frequency 1 1 1 1 1
## Proportion 0.2 0.2 0.2 0.2 0.2
## --------------------------------------------------------------------------------
summary(externamx)## año unidades_exportacion unidades_produccion unidades_ventas
## Min. :2017 Min. :2681806 Min. :3028481 Min. : 950063
## 1st Qu.:2018 1st Qu.:2706980 1st Qu.:3040178 1st Qu.:1014735
## Median :2019 Median :3253859 Median :3811068 Median :1317931
## Mean :2019 Mean :3096421 Mean :3546297 Mean :1248952
## 3rd Qu.:2020 3rd Qu.:3388305 3rd Qu.:3918603 3rd Qu.:1427086
## Max. :2021 Max. :3451157 Max. :3933154 Max. :1534943
## empleados_automotriz compensaciones_empleados salario_min Conf_Consumidor
## Min. :784000 Min. :506716 Min. :2435 Min. :36.32
## 1st Qu.:831000 1st Qu.:520113 1st Qu.:2688 1st Qu.:38.75
## Median :840000 Median :527878 Median :3123 Median :43.76
## Mean :833200 Mean :542087 Mean :3261 Mean :41.72
## 3rd Qu.:844000 3rd Qu.:567228 3rd Qu.:3748 3rd Qu.:44.87
## Max. :867000 Max. :588498 Max. :4310 Max. :44.90
## tasa_inflación X..Pob.Desocu X..Pob.Ocu
## Min. :2.830 Min. :2.910 Min. :96.21
## 1st Qu.:3.150 1st Qu.:3.150 1st Qu.:96.49
## Median :4.830 Median :3.360 Median :96.64
## Mean :4.988 Mean :3.344 Mean :96.66
## 3rd Qu.:6.770 3rd Qu.:3.510 3rd Qu.:96.85
## Max. :7.360 Max. :3.790 Max. :97.09
ggplot(externamx, aes(x=año, y=unidades_produccion)) +
geom_bar(stat="identity", fill="red") + scale_fill_grey() +
labs(title = "Año con más unidades de producción",
caption = "Industria MX",
x = "Año")boxplot(x = externamx$año, y = externamx$unidades_exportacion, main = "Concentración de datos en exportación",
xlab = "Año", ylab = "Exportación",
col = c("blue"))rhlimpia<- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/E2/RHCOLABLIMPIA.csv")tabla_estadisticos <- describe(rhlimpia)
tabla_estadisticos## rhlimpia
##
## 9 Variables 113 Observations
## --------------------------------------------------------------------------------
## nombre_completo
## n missing distinct
## 113 0 113
##
## lowest : ADELAIDA MENDOZA NAVARRO ADRIANA BADILLO LOZANO ADRIANA IRENE ZAPATA GARCIA ADRIANA PADILLO CASTILLO ALFREDO HERNANDEZ PASCUAL
## highest: VICTOR DE JESUS CARBAJAL FARIAS YOLANDA JUDITH LUNA LOPEZ YOLANDA LOPEZ RAMOS YUDITH ESMERALDA MARTINEZ RAMIREZ YULIANA MIREYA GARCIA PERALES
## --------------------------------------------------------------------------------
## edad
## n missing distinct Info Mean Gmd .05 .10
## 113 0 41 0.999 36.07 14.59 19.6 20.2
## .25 .50 .75 .90 .95
## 26.0 34.0 45.0 55.0 57.4
##
## lowest : 18 19 20 21 22, highest: 58 59 60 67 73
## --------------------------------------------------------------------------------
## genero
## n missing distinct
## 113 0 2
##
## Value FEMENINO MASCULINO
## Frequency 61 52
## Proportion 0.54 0.46
## --------------------------------------------------------------------------------
## antiguedad
## n missing distinct Info Mean Gmd .05 .10
## 113 0 12 0.821 1.425 2.171 0.0 0.0
## .25 .50 .75 .90 .95
## 0.0 0.0 2.0 4.8 7.4
##
## lowest : 0 1 2 3 4, highest: 7 8 9 11 12
##
## Value 0 1 2 3 4 5 6 7 8 9 11
## Frequency 63 19 10 6 3 4 1 1 2 1 2
## Proportion 0.558 0.168 0.088 0.053 0.027 0.035 0.009 0.009 0.018 0.009 0.018
##
## Value 12
## Frequency 1
## Proportion 0.009
## --------------------------------------------------------------------------------
## puesto
## n missing distinct
## 113 0 29
##
## lowest : AY. GENERAL AYUDANTE DE MANTENIMIENTO Ayudante general AYUDANTE GENERAL CHOFER
## highest: RESIDENTE SOLDADOR Supervisor de Máquin Supervisor de pegado SUPERVISORA
## --------------------------------------------------------------------------------
## mano_de_obra
## n missing distinct
## 113 0 2
##
## Value Directo Indirecto
## Frequency 76 37
## Proportion 0.673 0.327
## --------------------------------------------------------------------------------
## salario_diario
## n missing distinct Info Mean Gmd .05 .10
## 113 0 15 0.846 180.7 22.27 151.0 151.0
## .25 .50 .75 .90 .95
## 176.0 180.0 180.0 180.0 220.8
##
## lowest : 144 151 152 175 176, highest: 240 260 279 337 441
##
## Value 144 151 152 175 176 180 181 184 185 208 240
## Frequency 3 15 1 1 24 59 1 1 1 1 2
## Proportion 0.027 0.133 0.009 0.009 0.212 0.522 0.009 0.009 0.009 0.009 0.018
##
## Value 260 279 337 441
## Frequency 1 1 1 1
## Proportion 0.009 0.009 0.009 0.009
## --------------------------------------------------------------------------------
## colonia
## n missing distinct
## 113 0 73
##
## lowest : ALAMOS DEL PARQUE ANALCO 2 ANZURES BALCONES DE HUINALA C. H. BLAS CHUMACERO C.T.M
## highest: VILLAS DE HUINALA VILLAS DE SAN CARLOS VISTAS DEL RIO VIVIENDA DIGNA ZONA CENTRO
## --------------------------------------------------------------------------------
## municipio
## n missing distinct
## 113 0 9
##
## lowest : APODACA CAÑADA BLANCA GUADALUPE JUAREZ MONTERREY
## highest: MONTERREY PESQUERIA RAMOS ARIZPE SALTILLO SAN NICOLAS DE LOS G
##
## APODACA (72, 0.637), CAÑADA BLANCA (1, 0.009), GUADALUPE (6, 0.053), JUAREZ
## (10, 0.088), MONTERREY (4, 0.035), PESQUERIA (9, 0.080), RAMOS ARIZPE (4,
## 0.035), SALTILLO (5, 0.044), SAN NICOLAS DE LOS G (2, 0.018)
## --------------------------------------------------------------------------------
library( 'ggplot2' )
library( 'reshape2' )
rhlimpia1 <- dcast( data = rhlimpia, formula = salario_diario ~ genero, value.var = 'antiguedad', fun.aggregate = sum )
rhlimpia1 <- melt( data = rhlimpia1, id.vars = 'salario_diario')
rhlimpia1## salario_diario variable value
## 1 144 FEMENINO 10
## 2 151 FEMENINO 9
## 3 152 FEMENINO 5
## 4 175 FEMENINO 0
## 5 176 FEMENINO 21
## 6 180 FEMENINO 0
## 7 181 FEMENINO 0
## 8 184 FEMENINO 0
## 9 185 FEMENINO 0
## 10 208 FEMENINO 2
## 11 240 FEMENINO 2
## 12 260 FEMENINO 7
## 13 279 FEMENINO 0
## 14 337 FEMENINO 9
## 15 441 FEMENINO 8
## 16 144 MASCULINO 0
## 17 151 MASCULINO 10
## 18 152 MASCULINO 0
## 19 175 MASCULINO 5
## 20 176 MASCULINO 63
## 21 180 MASCULINO 0
## 22 181 MASCULINO 0
## 23 184 MASCULINO 0
## 24 185 MASCULINO 0
## 25 208 MASCULINO 0
## 26 240 MASCULINO 6
## 27 260 MASCULINO 0
## 28 279 MASCULINO 4
## 29 337 MASCULINO 0
## 30 441 MASCULINO 0
ggplot(data = rhlimpia1, aes( x = factor( salario_diario ), y = value, fill = variable ) ) +
geom_bar( stat = 'identity' )bajaslimpia <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/E2/RHBAJASLIMPIA.csv")summary(bajaslimpia)## nombre edad genero fecha_alta
## Length:237 Min. : 0.00 Length:237 Length:237
## Class :character 1st Qu.:23.00 Class :character Class :character
## Mode :character Median :29.00 Mode :character Mode :character
## Mean :30.52
## 3rd Qu.:37.00
## Max. :61.00
## motivo_baja dias_laborados fecha_baja puesto
## Length:237 Min. : 0.00 Length:237 Length:237
## Class :character 1st Qu.: 9.00 Class :character Class :character
## Mode :character Median : 21.00 Mode :character Mode :character
## Mean : 83.42
## 3rd Qu.: 49.00
## Max. :1966.00
## sal_imss colonia municipio estado
## Min. :144.4 Length:237 Length:237 Length:237
## 1st Qu.:180.7 Class :character Class :character Class :character
## Median :180.7 Mode :character Mode :character Mode :character
## Mean :178.6
## 3rd Qu.:180.7
## Max. :500.0
## estado_civil
## Length:237
## Class :character
## Mode :character
##
##
##
tabla.estadisticos0.1 <- describe (bajaslimpia)
tabla.estadisticos0.1## bajaslimpia
##
## 13 Variables 237 Observations
## --------------------------------------------------------------------------------
## nombre
## n missing distinct
## 237 0 234
##
## lowest : JOSE ISAIAS JAUREGUI ROJAS ABIGAIL LOPEZ ROSALES ABIGAIL PAULINO GERVACIO ADELINA HERNANDEZ MARTINEZ ADIEL FERNANDO ALCALA RINCON
## highest: YESSICA LIZBETH TORRES ENCINA YISENIA SANTOS VARGAS YOANA CRISTINA MEZA LLANAS YOSELIN MARIAM SORNIA SANTA CRUZ YULIBETH CUNDAPI RUIZ
## --------------------------------------------------------------------------------
## edad
## n missing distinct Info Mean Gmd .05 .10
## 237 0 40 0.998 30.52 11.08 19 20
## .25 .50 .75 .90 .95
## 23 29 37 46 49
##
## lowest : 0 18 19 20 21, highest: 52 54 56 57 61
## --------------------------------------------------------------------------------
## genero
## n missing distinct
## 237 0 2
##
## Value FEMENINO MASCULINO
## Frequency 140 97
## Proportion 0.591 0.409
## --------------------------------------------------------------------------------
## fecha_alta
## n missing distinct
## 237 0 137
##
## lowest : 01/02/22 01/07/22 01/10/21 01/12/21 02/02/22
## highest: 29/03/22 29/04/22 29/08/20 30/07/22 31/05/21
## --------------------------------------------------------------------------------
## motivo_baja
## n missing distinct
## 237 0 5
##
## lowest : ABANDONO BAJA POR FALTAS JUBILACION RENUNCIA VOLUNTARIA TERMINO DE CONTRATO
## highest: ABANDONO BAJA POR FALTAS JUBILACION RENUNCIA VOLUNTARIA TERMINO DE CONTRATO
##
## Value ABANDONO BAJA POR FALTAS JUBILACION
## Frequency 1 141 1
## Proportion 0.004 0.595 0.004
##
## Value RENUNCIA VOLUNTARIA TERMINO DE CONTRATO
## Frequency 86 8
## Proportion 0.363 0.034
## --------------------------------------------------------------------------------
## dias_laborados
## n missing distinct Info Mean Gmd .05 .10
## 237 0 95 1 83.42 128.2 1.0 3.0
## .25 .50 .75 .90 .95
## 9.0 21.0 49.0 148.4 377.0
##
## lowest : 0 1 2 3 4, highest: 1059 1236 1408 1429 1966
## --------------------------------------------------------------------------------
## fecha_baja
## n missing distinct
## 237 0 95
##
## lowest : 01/02/22 01/03/22 01/08/22 02/05/22 03/03/22
## highest: 29/06/22 29/07/22 30/06/22 30/07/22 31/01/22
## --------------------------------------------------------------------------------
## puesto
## n missing distinct
## 237 0 31
##
## lowest : ANALISTA DE NOMINAS /AUX DE R.H. AUXILIAR DE EMBARQUES AY. GENERAL AY.GENERAL (MATERIALES) AYUD.EMBARQUES
## highest: PRACTICANTE DE MTTO RESIDENTE RESIDENTE YANFENG SERVICIO AL CLIENTE SOLDADOR
## --------------------------------------------------------------------------------
## sal_imss
## n missing distinct Info Mean Gmd
## 237 0 9 0.515 178.6 11.11
##
## lowest : 144.45 151.61 151.67 176.72 180.68, highest: 180.68 182.68 183.68 338.36 500.00
##
## Value 144.45 151.61 151.67 176.72 180.68 182.68 183.68 338.36 500.00
## Frequency 1 28 2 15 186 2 1 1 1
## Proportion 0.004 0.118 0.008 0.063 0.785 0.008 0.004 0.004 0.004
## --------------------------------------------------------------------------------
## colonia
## n missing distinct
## 237 0 98
##
## lowest : ACANTO RESIDENCIAL ALAMOS DEL PARQUE ALBERTA ESCAMILLA ANALCO II ANALCO PONIENTE
## highest: VILLAS DE SAN CARLOS VILLAS DE SAN JOSE VILLAS DEL ORIENTE VILLAS REGINA VISTAS DEL RIO
## --------------------------------------------------------------------------------
## municipio
## n missing distinct
## 237 0 13
##
## lowest : APODACA CADEREYTA CIENEGA DE FLORES GUADALUPE JUAREZ
## highest: SALTILLO SAN NICOLAS DE LOS G SAN NICOLAS DE LOS GARZA SAN PDRO COAH ZUAZUA
## --------------------------------------------------------------------------------
## estado
## n missing distinct
## 237 0 3
##
## Value COAHUILA NUEVO LEÓN SALTILLO
## Frequency 9 227 1
## Proportion 0.038 0.958 0.004
## --------------------------------------------------------------------------------
## estado_civil
## n missing distinct
## 237 0 5
##
## lowest : CASADO DIVORCIADO SOLTERO Unión libre UNIÓN LIBRE
## highest: CASADO DIVORCIADO SOLTERO Unión libre UNIÓN LIBRE
##
## Value CASADO DIVORCIADO SOLTERO Unión libre UNIÓN LIBRE
## Frequency 64 3 110 1 59
## Proportion 0.270 0.013 0.464 0.004 0.249
## --------------------------------------------------------------------------------
ggplot(bajaslimpia, aes(x=genero, y=dias_laborados, fill=genero)) +
geom_bar(stat="identity") +
facet_grid(~motivo_baja) + scale_fill_brewer(palette = "Set2")del_planL <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/E2/DEL.PLANLIMPIA.csv")tabla_estadisticos1 <- describe (del_planL)
tabla_estadisticos1## del_planL
##
## 3 Variables 733 Observations
## --------------------------------------------------------------------------------
## cliente_planta
## n missing distinct
## 733 0 25
##
## lowest : ABC QUERETARO ANTOLIN ARTEAGA ANTOLIN TOLUCA DENSO HANON
## highest: YANFENG sm YF QRO YF RAMOS YFCF YFTO
## --------------------------------------------------------------------------------
## mes
## n missing distinct
## 733 0 12
##
## lowest : abr_22 ago_21 dic_21 ene_22 feb_22, highest: mar_22 may_22 nov_21 oct_21 sep_21
##
## Value abr_22 ago_21 dic_21 ene_22 feb_22 jul_21 jun_21 mar_22 may_22
## Frequency 73 55 60 76 55 57 38 70 70
## Proportion 0.100 0.075 0.082 0.104 0.075 0.078 0.052 0.095 0.095
##
## Value nov_21 oct_21 sep_21
## Frequency 61 64 54
## Proportion 0.083 0.087 0.074
## --------------------------------------------------------------------------------
## unidades
## n missing distinct Info Mean Gmd .05 .10
## 733 0 232 1 406.4 642.3 5.0 10.0
## .25 .50 .75 .90 .95
## 30.0 76.0 300.0 732.8 1600.0
##
## lowest : 1 2 3 4 5, highest: 6500 9600 13120 16354 17665
## --------------------------------------------------------------------------------
del_plan2$unidades<-as.numeric(del_plan2$unidades)
ggplot(del_plan, aes(x=cliente_planta, y=unidades, fill=cliente_planta)) +
geom_boxplot() boxplot(del_plan3$cliente_planta,del_plan3$unidades)class(del_plan2$unidades)## [1] "numeric"
del_perfL <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/E2/DEL.PERFLIMPIA2.csv")tabla_estadisticos3 <- describe (del_perfL)
tabla_estadisticos3## del_perfL
##
## 5 Variables 299 Observations
## --------------------------------------------------------------------------------
## X
## n missing distinct
## 299 0 299
##
## lowest : Abril 01th Abril 03th Abril 04th Abril 05th Abril 06th
## highest: September 26 th September 27 th September 28 th September 29 th September 30 th
## --------------------------------------------------------------------------------
## PRINTEL
## n missing distinct Info Mean Gmd
## 299 0 5 0.605 0.3679 0.5777
##
## lowest : 0 1 2 3 4, highest: 0 1 2 3 4
##
## Value 0 1 2 3 4
## Frequency 218 57 20 3 1
## Proportion 0.729 0.191 0.067 0.010 0.003
## --------------------------------------------------------------------------------
## MAHLE
## n missing distinct Info Mean Gmd .05 .10
## 299 0 11 0.882 2.11 1.577 0 0
## .25 .50 .75 .90 .95
## 1 3 3 3 3
##
## lowest : -11 -9 0 1 2, highest: 4 5 6 7 20
##
## Value -11 -9 0 1 2 3 4 5 6 7 20
## Frequency 1 1 54 24 67 139 7 3 1 1 1
## Proportion 0.003 0.003 0.181 0.080 0.224 0.465 0.023 0.010 0.003 0.003 0.003
## --------------------------------------------------------------------------------
## MAGNA
## n missing distinct Info Mean Gmd
## 299 0 1 0 0 0
##
## Value 0
## Frequency 299
## Proportion 1
## --------------------------------------------------------------------------------
## VARROC
## n missing distinct Info Mean Gmd
## 299 0 1 0 0 0
##
## Value 0
## Frequency 299
## Proportion 1
## --------------------------------------------------------------------------------
ggplot(bd_totalmes,aes(x=MAHLE, y=X,fill=MAHLE))+
geom_bar(stat="identity")+
geom_hline(yintercept=33,linetype="dashed",color="black")+
labs(x="Fecha",y="Delay in Minutes", color="Legend")+
ggtitle("Delays in Performance by Client")produccionlimpia <- read.csv ("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/E2/PRODUCCIONLIMPIA.csv")tabla_estadisticos4 <- describe(produccionlimpia)
tabla_estadisticos4## produccionlimpia
##
## 8 Variables 4182 Observations
## --------------------------------------------------------------------------------
## Fecha
## n missing distinct
## 4182 0 58
##
## lowest : 0022-07-15 0022-07-16 0022-07-18 0022-07-19 0022-07-20
## highest: 0022-09-16 0022-09-17 0022-09-19 0022-09-20 0022-09-21
## --------------------------------------------------------------------------------
## CLIENTE
## n missing distinct
## 4155 27 11
##
## lowest : DENSO HANON SYSTEMS HELLA MERIDIAN LIGHTWEIGHT STABILUS 1
## highest: TRMX VARROC VL-017-13939 VL-017-14086 YANFENG
## --------------------------------------------------------------------------------
## PIEZAS.PROG.
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 83 0.976 27.8 19.72 10 10
## .25 .50 .75 .90 .95
## 14 20 40 50 69
##
## lowest : 1 2 3 4 5, highest: 91 94 96 98 99
## --------------------------------------------------------------------------------
## TMO..MIN.
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 18 0.945 22 11.13 10 10
## .25 .50 .75 .90 .95
## 15 20 25 35 50
##
## lowest : 0 5 10 12 13, highest: 60 70 75 80 90
##
## Value 0 5 10 12 13 15 20 25 30 35 40
## Frequency 19 1 751 8 1 539 1385 916 76 101 130
## Proportion 0.005 0.000 0.180 0.002 0.000 0.129 0.331 0.219 0.018 0.024 0.031
##
## Value 45 50 60 70 75 80 90
## Frequency 11 133 62 15 17 5 12
## Proportion 0.003 0.032 0.015 0.004 0.004 0.001 0.003
## --------------------------------------------------------------------------------
## Laminas.procesadas
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 97 0.975 21.87 23.37 0 0
## .25 .50 .75 .90 .95
## 0 20 33 51 66
##
## lowest : 0 1 2 3 4, highest: 93 95 96 97 98
## --------------------------------------------------------------------------------
## FIN.de.PROCESO
## n missing distinct
## 3919 263 777
##
## lowest : 0 0:00 0:35 0:59 0.01, highest: 9.42 9.5 9.51 9.55 9.57
## --------------------------------------------------------------------------------
## TIEMPO.CALIDAD
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 17 0.614 0.9173 0.6442 0 0
## .25 .50 .75 .90 .95
## 1 1 1 1 1
##
## lowest : 0 1 2 3 4, highest: 12 17 21 22 25
##
## Value 0 1 2 3 4 5 6 7 8 9 10
## Frequency 965 3012 121 24 8 11 5 2 4 7 11
## Proportion 0.231 0.720 0.029 0.006 0.002 0.003 0.001 0.000 0.001 0.002 0.003
##
## Value 11 12 17 21 22 25
## Frequency 7 1 1 1 1 1
## Proportion 0.002 0.000 0.000 0.000 0.000 0.000
## --------------------------------------------------------------------------------
## laminas_procesadas
## n missing distinct Info Mean Gmd .05 .10
## 4182 0 97 0.975 21.87 23.37 0 0
## .25 .50 .75 .90 .95
## 0 20 33 51 66
##
## lowest : 0 1 2 3 4, highest: 93 95 96 97 98
## --------------------------------------------------------------------------------
ggplot(produccionlimpia, aes(x=PIEZAS.PROG., y=CLIENTE)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() +
labs(title = "Identificar el cliente con mayor piezas programadas",
caption = "Relación",
x = "Fecha")ggplot(produccionlimpia, aes(x=Laminas.procesadas, y=CLIENTE)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() +
labs(title = "Identificar el cliente con mayor laminas procesadas",
caption = "Relación",
x = "Fecha")mermalimpia <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/E2/MERMALIMPIA.csv")tabla_estadisticos5 <- describe(mermalimpia)
tabla_estadisticos5## mermalimpia
##
## 27 Variables 10 Observations
## --------------------------------------------------------------------------------
## Fecha
## n missing distinct
## 10 0 3
##
## Value 0 11/01/22 22/01/22
## Frequency 6 2 2
## Proportion 0.6 0.2 0.2
## --------------------------------------------------------------------------------
## ENERO
## n missing distinct
## 10 0 2
##
## Value 0 Enero
## Frequency 6 4
## Proportion 0.6 0.4
## --------------------------------------------------------------------------------
## KilosEnero
## n missing distinct Info Mean Gmd
## 10 0 5 0.788 1456 2120
##
## lowest : 0 2680 2990 3810 5080, highest: 0 2680 2990 3810 5080
##
## Value 0 2680 2990 3810 5080
## Frequency 6 1 1 1 1
## Proportion 0.6 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## Fecha1
## n missing distinct
## 10 0 3
##
## Value 0 18/02/22 24/02/22
## Frequency 4 5 1
## Proportion 0.4 0.5 0.1
## --------------------------------------------------------------------------------
## FEBRERO
## n missing distinct
## 10 0 2
##
## Value 0 Febrero
## Frequency 4 6
## Proportion 0.4 0.6
## --------------------------------------------------------------------------------
## KilosFebrero
## n missing distinct Info Mean Gmd
## 10 0 7 0.939 2283 2165
##
## lowest : 0 3410 3590 3650 3870, highest: 3590 3650 3870 3930 4380
##
## Value 0 3410 3590 3650 3870 3930 4380
## Frequency 4 1 1 1 1 1 1
## Proportion 0.4 0.1 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## Fecha2
## n missing distinct
## 10 0 7
##
## lowest : 0 03/03/22 08/03/22 11/03/22 16/03/22
## highest: 08/03/22 11/03/22 16/03/22 23/03/22 30/03/22
##
## Value 0 03/03/22 08/03/22 11/03/22 16/03/22 23/03/22 30/03/22
## Frequency 4 1 1 1 1 1 1
## Proportion 0.4 0.1 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## MARZO
## n missing distinct
## 10 0 2
##
## Value 0 Marzo
## Frequency 4 6
## Proportion 0.4 0.6
## --------------------------------------------------------------------------------
## KilosMarzo
## n missing distinct Info Mean Gmd
## 10 0 7 0.939 2247 2197
##
## lowest : 0 2980 3290 3810 4000, highest: 3290 3810 4000 4190 4200
##
## Value 0 2980 3290 3810 4000 4190 4200
## Frequency 4 1 1 1 1 1 1
## Proportion 0.4 0.1 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## Fecha3
## n missing distinct
## 10 0 6
##
## lowest : 0 04/04/22 11/04/22 14/04/22 21/04/22
## highest: 04/04/22 11/04/22 14/04/22 21/04/22 27/04/22
##
## Value 0 04/04/22 11/04/22 14/04/22 21/04/22 27/04/22
## Frequency 5 1 1 1 1 1
## Proportion 0.5 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## ABRIL
## n missing distinct
## 10 0 2
##
## Value 0 Abril
## Frequency 5 5
## Proportion 0.5 0.5
## --------------------------------------------------------------------------------
## KilosAbril
## n missing distinct Info Mean Gmd
## 10 0 6 0.879 1882 2217
##
## lowest : 0 2950 3690 3940 4050, highest: 2950 3690 3940 4050 4190
##
## Value 0 2950 3690 3940 4050 4190
## Frequency 5 1 1 1 1 1
## Proportion 0.5 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## Fecha4
## n missing distinct
## 10 0 6
##
## lowest : 0 02/05/22 09/05/22 14/05/22 24/05/22
## highest: 02/05/22 09/05/22 14/05/22 24/05/22 25/05/22
##
## Value 0 02/05/22 09/05/22 14/05/22 24/05/22 25/05/22
## Frequency 5 1 1 1 1 1
## Proportion 0.5 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## MAYO
## n missing distinct
## 10 0 2
##
## Value 0 Mayo
## Frequency 5 5
## Proportion 0.5 0.5
## --------------------------------------------------------------------------------
## KilosMayo
## n missing distinct Info Mean Gmd
## 10 0 6 0.879 2341 2840
##
## lowest : 0 3680 4310 4510 4770, highest: 3680 4310 4510 4770 6140
##
## Value 0 3680 4310 4510 4770 6140
## Frequency 5 1 1 1 1 1
## Proportion 0.5 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## Fecha5
## n missing distinct
## 10 0 5
##
## lowest : 0 07/06/22 15/06/22 20/06/22 27/06/22
## highest: 0 07/06/22 15/06/22 20/06/22 27/06/22
##
## Value 0 07/06/22 15/06/22 20/06/22 27/06/22
## Frequency 6 1 1 1 1
## Proportion 0.6 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## JUNIO
## n missing distinct
## 10 0 2
##
## Value 0 Junio
## Frequency 6 4
## Proportion 0.6 0.4
## --------------------------------------------------------------------------------
## KilosJunio
## n missing distinct Info Mean Gmd
## 10 0 5 0.788 1828 2495
##
## lowest : 0 4260 4330 4680 5010, highest: 0 4260 4330 4680 5010
##
## Value 0 4260 4330 4680 5010
## Frequency 6 1 1 1 1
## Proportion 0.6 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## Fecha6
## n missing distinct
## 10 0 6
##
## lowest : 0 04/07/22 11/07/22 16/07/22 21/07/22
## highest: 04/07/22 11/07/22 16/07/22 21/07/22 27/07/22
##
## Value 0 04/07/22 11/07/22 16/07/22 21/07/22 27/07/22
## Frequency 5 1 1 1 1 1
## Proportion 0.5 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## JULIO
## n missing distinct
## 10 0 2
##
## Value 0 Julio
## Frequency 5 5
## Proportion 0.5 0.5
## --------------------------------------------------------------------------------
## KilosJulio
## n missing distinct Info Mean Gmd
## 10 0 6 0.879 1937 2437
##
## lowest : 0 2130 3920 3960 4130, highest: 2130 3920 3960 4130 5230
##
## Value 0 2130 3920 3960 4130 5230
## Frequency 5 1 1 1 1 1
## Proportion 0.5 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## Fecha7
## n missing distinct
## 10 0 10
##
## lowest : 0 08/08/22 10/08/22 11/08/22 13/08/22
## highest: 15/08/22 22/08/22 29/08/22 30/08/22 31/08/22
##
## Value 0 08/08/22 10/08/22 11/08/22 13/08/22 15/08/22 22/08/22
## Frequency 1 1 1 1 1 1 1
## Proportion 0.1 0.1 0.1 0.1 0.1 0.1 0.1
##
## Value 29/08/22 30/08/22 31/08/22
## Frequency 1 1 1
## Proportion 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## AGOSTO
## n missing distinct
## 10 0 2
##
## Value 0 Agosto
## Frequency 1 9
## Proportion 0.1 0.9
## --------------------------------------------------------------------------------
## KilosAgosto
## n missing distinct Info Mean Gmd
## 10 0 9 0.994 3210 1715
##
## lowest : 0 1040 3140 3270 3780, highest: 3780 4200 4210 4240 5080
##
## Value 0 1040 3140 3270 3780 4200 4210 4240 5080
## Frequency 1 1 2 1 1 1 1 1 1
## Proportion 0.1 0.1 0.2 0.1 0.1 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## Fecha8
## n missing distinct
## 10 0 5
##
## lowest : 0 05/09/22 07/09/22 15/09/22 21/09/22
## highest: 0 05/09/22 07/09/22 15/09/22 21/09/22
##
## Value 0 05/09/22 07/09/22 15/09/22 21/09/22
## Frequency 6 1 1 1 1
## Proportion 0.6 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
## SEPTIEMBRE
## n missing distinct
## 10 0 2
##
## Value 0 Septiembre
## Frequency 6 4
## Proportion 0.6 0.4
## --------------------------------------------------------------------------------
## KilosSeptiembre
## n missing distinct Info Mean Gmd
## 10 0 5 0.788 1359 1903
##
## lowest : 0 2830 3050 3739 3967, highest: 0 2830 3050 3739 3967
##
## Value 0 2830 3050 3739 3967
## Frequency 6 1 1 1 1
## Proportion 0.6 0.1 0.1 0.1 0.1
## --------------------------------------------------------------------------------
scraplimpia <- read.csv ("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/E2/SCRAPLIMPIA.csv")tabla_estadisticos5 <- describe (scraplimpia)
tabla_estadisticos5## scraplimpia
##
## 6 Variables 250 Observations
## --------------------------------------------------------------------------------
## Fecha
## n missing distinct
## 250 0 26
##
## lowest : 2022-08-01 2022-08-02 2022-08-03 2022-08-04 2022-08-05
## highest: 2022-08-26 2022-08-27 2022-08-29 2022-08-30 2022-08-31
## --------------------------------------------------------------------------------
## Hora
## n missing distinct Info Mean Gmd .05 .10
## 250 0 12 0.975 12 3.417 9 9
## .25 .50 .75 .90 .95
## 9 11 14 16 18
##
## lowest : 8 9 10 11 12, highest: 15 16 17 18 19
##
## Value 8 9 10 11 12 13 14 15 16 17 18
## Frequency 9 60 50 17 15 17 24 15 21 5 5
## Proportion 0.036 0.240 0.200 0.068 0.060 0.068 0.096 0.060 0.084 0.020 0.020
##
## Value 19
## Frequency 12
## Proportion 0.048
## --------------------------------------------------------------------------------
## Producto
## n missing distinct
## 250 0 95
##
## lowest : [2065WY AS 30 99 0000 00 000 TAPA - BOX 2064WY] BOX 2064WY [241B EXPORT CAJA] 241B. Export. Caja. [341332 CELDA - U611 & U625] 341332. U611. U625. Celda Troquelada. [341332 CHAROLA - U611 & U625] 341332. U611. U625. Charola Troquelada. [341332 DIVISOR - U611 & U625] 341332. U611. U625. Divisor Troquelado.
## highest: [TMC XXX] Armrest. Caja RSC. [TR11910 CHAROLA C/2 DIV #20 SMOOTH C/32 CAVIDADES] TR11910. U725. DMS. ITB. Charola con ITB. [TR12438 TAPA ICP 539 TAPA 2415-2 EN CPARTÓN SENCILLO CORRUGADO] 18840. CD539. Tapa. [TR12440 TAPA P558] 18842. P558. Tapa. [TR13776 CAJA RSC CK 44 ECT C/ PORTA ETIQUETA] TR13776. Caja con Porta Etiqueta.
## --------------------------------------------------------------------------------
## Cantidad
## n missing distinct Info Mean Gmd .05 .10
## 250 0 33 0.958 6.696 8.607 1 1
## .25 .50 .75 .90 .95
## 1 2 7 16 24
##
## lowest : 0.0 1.0 2.0 2.5 3.0, highest: 51.0 56.0 60.0 80.0 96.0
## --------------------------------------------------------------------------------
## Ubicación.de.origen
## n missing distinct
## 250 0 3
##
## Value SAB/Calidad/Entrega de PT SAB/Post-Production
## Frequency 58 13
## Proportion 0.232 0.052
##
## Value SAB/Pre-Production
## Frequency 179
## Proportion 0.716
## --------------------------------------------------------------------------------
## Ubicación.de.desecho
## n missing
## 250 0
## distinct value
## 1 Virtual Locations/Scrapped
##
## Value Virtual Locations/Scrapped
## Frequency 250
## Proportion 1
## --------------------------------------------------------------------------------
ggplot(scraplimpia, aes(x=Ubicación.de.origen, y=Cantidad)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() +
labs(title = "Origen de desecho",
caption = "Empresa FORM",
x = "Ubicación de origen")externa <- read.csv("/Users/ivannagarza/Desktop/TEC/7 SEMESTRE/RETO/us_motor_production_and_domestic_sales.csv")
summary(externa)## Year Total_Production Production_Passenger_Cars
## Min. :2007 Min. : 5710 Min. :1924
## 1st Qu.:2010 1st Qu.: 8709 1st Qu.:2745
## Median :2014 Median :10823 Median :3382
## Mean :2014 Mean :10077 Mean :3326
## 3rd Qu.:2017 3rd Qu.:11268 3rd Qu.:4061
## Max. :2020 Max. :12179 Max. :4369
## NA's :8 NA's :8 NA's :8
## Production_Commercial_Vehicles Domestic_Sales Sales_Passenger_Cars
## Min. :3514 Min. : 7868 Min. :2560
## 1st Qu.:5820 1st Qu.:10474 1st Qu.:3865
## Median :6891 Median :12583 Median :4542
## Mean :6751 Mean :11996 Mean :4491
## 3rd Qu.:8095 3rd Qu.:13669 3rd Qu.:5184
## Max. :8512 Max. :14128 Max. :5610
## NA's :8 NA's :8 NA's :8
## Sales_Commercial_Vehicles US_Unemployment US_Consumer_Confidence
## Min. : 4309 Min. :3.680 Min. :63.75
## 1st Qu.: 6088 1st Qu.:4.685 1st Qu.:73.02
## Median : 7634 Median :5.980 Median :82.83
## Mean : 7505 Mean :6.430 Mean :82.29
## 3rd Qu.: 8964 3rd Qu.:8.088 3rd Qu.:92.67
## Max. :10133 Max. :9.610 Max. :98.37
## NA's :8 NA's :8 NA's :8
## US_Min_Hour_Wage
## Min. :5.500
## 1st Qu.:7.250
## Median :7.250
## Mean :7.025
## 3rd Qu.:7.250
## Max. :7.250
## NA's :8
library(jtools)
library(lmtest)
library(car)
library(olsrr) regresion <- lm(Production_Commercial_Vehicles ~ US_Unemployment + US_Consumer_Confidence + US_Min_Hour_Wage , data=externa)
summary(regresion)##
## Call:
## lm(formula = Production_Commercial_Vehicles ~ US_Unemployment +
## US_Consumer_Confidence + US_Min_Hour_Wage, data = externa)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1198.1 -257.4 109.0 286.7 623.0
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2217.25 2387.79 -0.929 0.3750
## US_Unemployment -226.91 159.03 -1.427 0.1841
## US_Consumer_Confidence 82.82 28.06 2.952 0.0145 *
## US_Min_Hour_Wage 514.11 387.30 1.327 0.2139
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 525.3 on 10 degrees of freedom
## (8 observations deleted due to missingness)
## Multiple R-squared: 0.9082, Adjusted R-squared: 0.8807
## F-statistic: 32.99 on 3 and 10 DF, p-value: 1.692e-05
Definición de variables Variable dependiente Producción de vehículos comerciales –> son vehículos diseñados para transportar mercancia y pasajeros con fines de negocio.
Variables independientes Desempleo –> Es la tasa de desempleo en el país.
Confianza del consumidor –> Es un indicador económico que mide el grado de optimismo que los consumidores sienten sobre el estado general de la economía.
Salario Mínimo por Hora –> El salario mínimo en Estados Unidos depende del estado sin embargo, en DC. esta en $16.10 dólares la hora.
Observando el resumen de la regresión podemos observar cómo la confianza del consumidor tiene relación con la variable dependiente, tal y cómo podemos observar a continuación.
effect_plot(regresion,pred=US_Consumer_Confidence,interval=TRUE)predict_lm1 <- predict(regresion, externa)
predict_lm1 <- data.frame(Production_Commercial_Vehicles_pred = predict_lm1, Production_Commercial_Vehicles = externa$Production_Commercial_Vehicles,
US_Unemployment = externa$US_Unemployment, US_Consumer_Confidence = externa$US_Consumer_Confidence,
US_Min_Hour_Wage = externa$US_Min_Hour_Wage)head(predict_lm1)## Production_Commercial_Vehicles_pred Production_Commercial_Vehicles
## 1 6649.654 6885.04
## 2 4933.841 4940.90
## 3 4711.949 3513.84
## 4 5279.136 5011.99
## 5 5061.577 5684.54
## 6 6015.554 6226.52
## US_Unemployment US_Consumer_Confidence US_Min_Hour_Wage
## 1 4.62 85.58 5.50
## 2 5.80 63.75 6.20
## 3 9.28 66.26 6.90
## 4 9.61 71.84 7.25
## 5 8.93 67.35 7.25
## 6 8.08 76.54 7.25
regresion2 <- lm(US_Consumer_Confidence ~ Total_Production + Sales_Passenger_Cars + Sales_Commercial_Vehicles , data=externa)
summary(regresion2)##
## Call:
## lm(formula = US_Consumer_Confidence ~ Total_Production + Sales_Passenger_Cars +
## Sales_Commercial_Vehicles, data = externa)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.3693 -2.6645 0.3144 1.6566 7.5678
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 14.889722 10.751402 1.385 0.1962
## Total_Production -0.006366 0.004427 -1.438 0.1810
## Sales_Passenger_Cars 0.010603 0.005900 1.797 0.1025
## Sales_Commercial_Vehicles 0.011184 0.003568 3.135 0.0106 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.246 on 10 degrees of freedom
## (8 observations deleted due to missingness)
## Multiple R-squared: 0.9026, Adjusted R-squared: 0.8733
## F-statistic: 30.88 on 3 and 10 DF, p-value: 2.279e-05
Definición de variables
Variable dependiente
Confianza del consumidor –> Es un indicador
económico que mide el grado de optimismo que los consumidores sienten
sobre el estado general de la economía.
Variables independientes
Producción total –> La producción total en el país
de todo tipo de vehículos
Venta de Autos de pasageros –> son vehículos utilizados en el día a día para un uso personal, por lo tanto este indicador muestra las ventas totales en el país de este tipo de vehículo.
Venta de Autos comerciales –> son vehículos diseñados para transportar mercancia y pasajeros con fines de negocio, por lo tanto este indicador habla de las ventas en el país.
effect_plot(regresion2,pred=Sales_Commercial_Vehicles,interval=TRUE)predict_lm2 <- predict(regresion2, externa)
predict_lm2 <- data.frame(US_Consumer_Confidence_pred = predict_lm2, US_Consumer_Confidence = externa$US_Consumer_Confidence,
Total_Production = externa$Total_Production, Sales_Passenger_Cars = externa$Sales_Passenger_Cars,
Sales_Commercial_Vehicles = externa$Sales_Commercial_Vehicles)head(predict_lm2)## US_Consumer_Confidence_pred US_Consumer_Confidence Total_Production
## 1 85.31451 85.58 10752.31
## 2 70.11933 63.75 8672.28
## 3 64.46456 66.26 5710.29
## 4 64.27222 71.84 7743.75
## 5 70.39494 67.35 8662.26
## 6 75.65139 76.54 10335.53
## Sales_Passenger_Cars Sales_Commercial_Vehicles
## 1 5197.27 7489.75
## 2 4490.86 5616.89
## 3 3558.28 4309.48
## 4 3791.50 5228.59
## 5 4145.96 5962.80
## 6 5119.84 6461.93
externamx <- read.csv ("/Users/ivannagarza/Downloads/industria_automotriz_mx (1).csv")
summary (externamx)## año unidades_exportacion unidades_produccion unidades_ventas
## Min. :2017 Min. :2681806 Min. :3028481 Min. : 950063
## 1st Qu.:2018 1st Qu.:2706980 1st Qu.:3040178 1st Qu.:1014735
## Median :2019 Median :3253859 Median :3811068 Median :1317931
## Mean :2019 Mean :3096421 Mean :3546297 Mean :1248952
## 3rd Qu.:2020 3rd Qu.:3388305 3rd Qu.:3918603 3rd Qu.:1427086
## Max. :2021 Max. :3451157 Max. :3933154 Max. :1534943
## empleados_automotriz compensaciones_empleados salario_min Conf_Consumidor
## Min. :784000 Min. :506716 Min. :2435 Min. :36.32
## 1st Qu.:831000 1st Qu.:520113 1st Qu.:2688 1st Qu.:38.75
## Median :840000 Median :527878 Median :3123 Median :43.76
## Mean :833200 Mean :542087 Mean :3261 Mean :41.72
## 3rd Qu.:844000 3rd Qu.:567228 3rd Qu.:3748 3rd Qu.:44.87
## Max. :867000 Max. :588498 Max. :4310 Max. :44.90
## tasa_inflación X..Pob.Desocu X..Pob.Ocu
## Min. :2.830 Min. :2.910 Min. :96.21
## 1st Qu.:3.150 1st Qu.:3.150 1st Qu.:96.49
## Median :4.830 Median :3.360 Median :96.64
## Mean :4.988 Mean :3.344 Mean :96.66
## 3rd Qu.:6.770 3rd Qu.:3.510 3rd Qu.:96.85
## Max. :7.360 Max. :3.790 Max. :97.09
library(jtools)
library(lmtest)
library(car)
library(olsrr) regresion1 <- lm(Conf_Consumidor ~ unidades_exportacion + unidades_produccion + unidades_ventas , data=externamx)
summary(regresion1)##
## Call:
## lm(formula = Conf_Consumidor ~ unidades_exportacion + unidades_produccion +
## unidades_ventas, data = externamx)
##
## Residuals:
## 1 2 3 4 5
## 0.02398 -0.12035 0.11003 -0.05856 0.04489
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.317e+01 1.367e+00 38.91 0.0164 *
## unidades_exportacion 6.702e-05 1.721e-06 38.95 0.0163 *
## unidades_produccion -8.036e-05 2.577e-06 -31.18 0.0204 *
## unidades_ventas 5.284e-05 2.582e-06 20.46 0.0311 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1806 on 1 degrees of freedom
## Multiple R-squared: 0.9995, Adjusted R-squared: 0.9979
## F-statistic: 635.2 on 3 and 1 DF, p-value: 0.02916
Definición de variables
Variable dependiente
Confianza del consumidor –> Es un indicador
económico que mide el grado de optimismo que los consumidores sienten
sobre el estado general de la economía.
Variables independientes
Unidades exportadas –> La cantidad de exportaciones
en la industria automotriz del país en el año asignado.
Unidades producidas –> La cantidad de producción en la industria automotriz del país en el año asignado.
Unidades Venta –> La cantidad de unidades vendidos en el año asignado en el país.
predict_lm3 <- predict(regresion1, externamx)
predict_lm3 <- data.frame(Conf_Consumidor_pred = predict_lm3, Conf_Consumidor = externamx$Conf_Consumidor,
unidades_exportacion = externamx$unidades_exportacion, unidades_produccion = externamx$unidades_produccion,
unidades_ventas = externamx$unidades_ventas)head(predict_lm3)## Conf_Consumidor_pred Conf_Consumidor unidades_exportacion unidades_produccion
## 1 36.29152 36.3155 3253859 3933154
## 2 44.98575 44.8654 3451157 3918603
## 3 43.64737 43.7574 3388305 3811068
## 4 38.80726 38.7487 2681806 3040178
## 5 44.85151 44.8964 2706980 3028481
## unidades_ventas
## 1 1534943
## 2 1427086
## 3 1317931
## 4 950063
## 5 1014735
effect_plot(regresion1,pred=unidades_exportacion,interval=TRUE)effect_plot(regresion1,pred=unidades_produccion,interval=TRUE)effect_plot(regresion1,pred=unidades_ventas,interval=TRUE)regresion4 <- lm(tasa_inflación ~ unidades_exportacion + unidades_produccion + unidades_ventas , data=externamx)
summary(regresion4)##
## Call:
## lm(formula = tasa_inflación ~ unidades_exportacion + unidades_produccion +
## unidades_ventas, data = externamx)
##
## Residuals:
## 1 2 3 4 5
## 0.02824 -0.14171 0.12957 -0.06895 0.05286
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.199e+01 1.609e+00 19.878 0.0320 *
## unidades_exportacion 1.557e-05 2.026e-06 7.682 0.0824 .
## unidades_produccion -3.886e-05 3.035e-06 -12.805 0.0496 *
## unidades_ventas 5.013e-05 3.040e-06 16.487 0.0386 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2126 on 1 degrees of freedom
## Multiple R-squared: 0.9973, Adjusted R-squared: 0.9893
## F-statistic: 124 on 3 and 1 DF, p-value: 0.0659
Definición de variables
Variable dependiente
Tasa de inflación –> Incrementos de precio, el
coeficiente que muestra la variación porcentual de los precios.
Variables independientes
Unidades exportadas –> La cantidad de exportaciones
en la industria automotriz del país en el año asignado.
Unidades producidas –> La cantidad de producción en la industria automotriz del país en el año asignado.
Unidades Venta –> La cantidad de unidades vendidos en el año asignado en el país.
predict_lm4 <- predict(regresion4, externamx)
predict_lm4 <- data.frame(tasa_inflación_pred = predict_lm4, tasa_inflación = externamx$tasa_inflación,
unidades_exportacion = externamx$unidades_exportacion, unidades_produccion = externamx$unidades_produccion,
unidades_ventas = externamx$unidades_ventas)head(predict_lm4)## tasa_inflación_pred tasa_inflación unidades_exportacion unidades_produccion
## 1 6.741760 6.77 3253859 3933154
## 2 4.971710 4.83 3451157 3918603
## 3 2.700432 2.83 3388305 3811068
## 4 3.218953 3.15 2681806 3040178
## 5 7.307144 7.36 2706980 3028481
## unidades_ventas
## 1 1534943
## 2 1427086
## 3 1317931
## 4 950063
## 5 1014735
effect_plot(regresion4,pred=unidades_exportacion,interval=TRUE)effect_plot(regresion4,pred=unidades_produccion,interval=TRUE)effect_plot(regresion4,pred=unidades_ventas,interval=TRUE)Instalar librerias
library(foreign)
library(dplyr) # data manipulation
library(ggplot2) # data visualization
#install.packages("psych")
library(psych) # functions for multivariate analysis
library(corrplot) # correlation plots
#install.packages("jtools")
library(jtools) # presentation of regression analysis
library(lmtest) # diagnostic checks - linear regression analysis
library(car) # diagnostic checks - linear regression analysis
library(factoextra) # provides functions to extract and visualize the output of exploratory multivariate data analyses
#install.packages("ggfortify")
library(ggfortify) # data visualization tools for statistical analysis results
library(plyr)
library(base)
library(tibble)bajasdata <-read.csv("/Users/ivannagarza/Downloads/RHBAJASLIMPIA1.csv")
summary(bajasdata)## nombre edad genero fecha_alta
## Length:237 Min. : 0.00 Length:237 Length:237
## Class :character 1st Qu.:23.00 Class :character Class :character
## Mode :character Median :29.00 Mode :character Mode :character
## Mean :30.52
## 3rd Qu.:37.00
## Max. :61.00
## motivo_baja dias_laborados fecha_baja puesto
## Length:237 Min. : 0.00 Length:237 Length:237
## Class :character 1st Qu.: 9.00 Class :character Class :character
## Mode :character Median : 21.00 Mode :character Mode :character
## Mean : 83.42
## 3rd Qu.: 49.00
## Max. :1966.00
## sal_imss colonia municipio estado
## Min. :144.4 Length:237 Length:237 Length:237
## 1st Qu.:180.7 Class :character Class :character Class :character
## Median :180.7 Mode :character Mode :character Mode :character
## Mean :178.6
## 3rd Qu.:180.7
## Max. :500.0
## estado_civil
## Length:237
## Class :character
## Mode :character
##
##
##
bajasdata1<-bajasdata
bajasdata1<-subset(bajasdata,select = -c(genero,fecha_alta,motivo_baja,puesto,estado,nombre,colonia,municipio,motivo_baja, estado_civil, dias_laborados, fecha_baja))
summary(bajasdata1)## edad sal_imss
## Min. : 0.00 Min. :144.4
## 1st Qu.:23.00 1st Qu.:180.7
## Median :29.00 Median :180.7
## Mean :30.52 Mean :178.6
## 3rd Qu.:37.00 3rd Qu.:180.7
## Max. :61.00 Max. :500.0
bajasdata2 <- bajasdata1
bajasdata2<-bajasdata1[-c(97,149),]bajas_data_norm <- scale(bajasdata2[1:2])library ()
fviz_nbclust(bajas_data_norm, kmeans, method="wss")+
geom_vline(xintercept=4, linetype=2)+
labs(subtitle = "Elbow method") edad_cluster1<-kmeans(bajas_data_norm,3)
edad_cluster1## K-means clustering with 3 clusters of sizes 69, 121, 45
##
## Cluster means:
## edad sal_imss
## 1 0.2811317 0.2784633
## 2 -0.7792176 -0.1288413
## 3 1.6641609 -0.0805373
##
## Clustering vector:
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## 1 1 2 2 2 3 2 2 3 2 2 1 2 1 1 2 2 2 2 2
## 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
## 2 3 2 1 3 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2
## 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
## 2 2 2 2 2 2 2 2 3 3 3 3 1 3 2 2 3 2 2 3
## 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
## 2 2 1 2 2 3 2 2 2 2 2 2 1 2 1 2 1 2 2 3
## 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 98 99 100 101
## 2 2 2 2 3 2 3 2 2 2 1 3 3 2 2 2 3 2 2 1
## 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
## 2 2 3 1 2 2 1 2 1 1 2 1 1 2 1 1 1 3 3 3
## 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
## 2 2 2 2 2 1 2 1 3 2 1 2 3 2 2 2 1 3 1 3
## 142 143 144 145 146 147 148 150 151 152 153 154 155 156 157 158 159 160 161 162
## 1 1 1 3 3 2 1 1 1 2 2 2 1 3 3 2 1 2 1 3
## 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
## 3 3 3 1 3 2 2 1 2 2 3 1 3 2 3 1 1 3 1 1
## 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
## 2 2 2 1 3 3 1 2 2 1 1 1 1 1 1 1 1 2 1 2
## 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
## 1 1 2 1 3 1 2 2 2 3 2 2 2 1 1 2 2 1 1 1
## 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
## 2 2 1 2 2 2 2 3 1 3 2 2 2 2 2
##
## Within cluster sum of squares by cluster:
## [1] 204.19421 35.55499 17.05330
## (between_SS / total_SS = 45.1 %)
##
## Available components:
##
## [1] "cluster" "centers" "totss" "withinss" "tot.withinss"
## [6] "betweenss" "size" "iter" "ifault"
fviz_cluster(edad_cluster1,data=bajas_data_norm)bajasdata3<- bajasdata2
bajasdata3$Clusters<-edad_cluster1$cluster
bajasdata4<-bajasdata3 %>% group_by(Clusters) %>% summarise(edad=max(edad)) %>% arrange(desc(edad))
bajasdata3$Cluster_Names<-factor(bajasdata3$Clusters,levels = c(1,2,3),
labels=c("Jubilación", "Joven", "Adulto"))bajasdata5 <- bajasdata3 %>% dplyr:: group_by(Cluster_Names) %>% dplyr:: summarize(edad_años=max(edad),
sal_imss=mean(sal_imss),
count=n())clusters<-as.data.frame(bajasdata5)
clusters## Cluster_Names edad_años sal_imss count
## 1 Jubilación 40 185.7365 69
## 2 Joven 32 175.3303 121
## 3 Adulto 61 176.5644 45
ggplot(bajasdata5, aes(x=Cluster_Names,y=edad_años,fill= Cluster_Names,label=round(edad_años,digits=2))) +
geom_col() +
geom_text()ggplot(bajasdata5,aes(x=Cluster_Names,y=sal_imss ,fill= Cluster_Names,label=round(sal_imss,digits=2))) +
geom_col() +
geom_text()ggplot(bajasdata3, aes(x=Cluster_Names, y=edad, fill=Cluster_Names)) +
geom_boxplot()+
ggtitle("Dispersion of 'Edad' by Clusters Names")ggplot(bajasdata3, aes(x=Cluster_Names, y=sal_imss, fill=Cluster_Names)) +
geom_boxplot()+
ggtitle("Dispersion of 'Salario_Diario' by Clusters Names")RHBAJAS <-read.csv("/Users/ivannagarza/Downloads/RHBAJASLIMPIA1.csv")summary(RHBAJAS)## nombre edad genero fecha_alta
## Length:237 Min. : 0.00 Length:237 Length:237
## Class :character 1st Qu.:23.00 Class :character Class :character
## Mode :character Median :29.00 Mode :character Mode :character
## Mean :30.52
## 3rd Qu.:37.00
## Max. :61.00
## motivo_baja dias_laborados fecha_baja puesto
## Length:237 Min. : 0.00 Length:237 Length:237
## Class :character 1st Qu.: 9.00 Class :character Class :character
## Mode :character Median : 21.00 Mode :character Mode :character
## Mean : 83.42
## 3rd Qu.: 49.00
## Max. :1966.00
## sal_imss colonia municipio estado
## Min. :144.4 Length:237 Length:237 Length:237
## 1st Qu.:180.7 Class :character Class :character Class :character
## Median :180.7 Mode :character Mode :character Mode :character
## Mean :178.6
## 3rd Qu.:180.7
## Max. :500.0
## estado_civil
## Length:237
## Class :character
## Mode :character
##
##
##
str(RHBAJAS)## 'data.frame': 237 obs. of 13 variables:
## $ nombre : chr "MARIO VALDEZ ORTIZ" "ISABEL BARRIOS MENDEZ" "MARIA ELIZABETH GOMEZ HERNANDEZ" "ALONDRA ABIGAIL ESCARCIA GOMEZ" ...
## $ edad : int 32 36 23 21 29 46 29 31 50 19 ...
## $ genero : chr "MASCULINO" "FEMENINO" "FEMENINO" "FEMENINO" ...
## $ fecha_alta : chr "09/03/20" "09/11/21" "10/11/21" "10/11/21" ...
## $ motivo_baja : chr "RENUNCIA VOLUNTARIA" "RENUNCIA VOLUNTARIA" "RENUNCIA VOLUNTARIA" "RENUNCIA VOLUNTARIA" ...
## $ dias_laborados: int 628 60 59 59 51 37 37 31 18 224 ...
## $ fecha_baja : chr "27/11/21" "08/01/22" "08/01/22" "08/01/22" ...
## $ puesto : chr "DISEÑO" "AYUDANTE GENERAL" "AYUDANTE GENERAL" "AYUDANTE GENERAL" ...
## $ sal_imss : num 500 152 152 152 152 ...
## $ colonia : chr "SAN NICOLAS DE LOS G" "COLINAS DEL AEROPÑUERTO" "PUEBLO NUEVO" "PUEBLO NUEVO" ...
## $ municipio : chr "SAN NICOLAS DE LOS G" "PESQUERIA" "APODACA" "APODACA" ...
## $ estado : chr "NUEVO LEÓN" "NUEVO LEÓN" "NUEVO LEÓN" "NUEVO LEÓN" ...
## $ estado_civil : chr "SOLTERO" "UNIÓN LIBRE" "CASADO" "SOLTERO" ...
describe(RHBAJAS)## RHBAJAS
##
## 13 Variables 237 Observations
## --------------------------------------------------------------------------------
## nombre
## n missing distinct
## 237 0 234
##
## lowest : JOSE ISAIAS JAUREGUI ROJAS ABIGAIL LOPEZ ROSALES ABIGAIL PAULINO GERVACIO ADELINA HERNANDEZ MARTINEZ ADIEL FERNANDO ALCALA RINCON
## highest: YESSICA LIZBETH TORRES ENCINA YISENIA SANTOS VARGAS YOANA CRISTINA MEZA LLANAS YOSELIN MARIAM SORNIA SANTA CRUZ YULIBETH CUNDAPI RUIZ
## --------------------------------------------------------------------------------
## edad
## n missing distinct Info Mean Gmd .05 .10
## 237 0 40 0.998 30.52 11.08 19 20
## .25 .50 .75 .90 .95
## 23 29 37 46 49
##
## lowest : 0 18 19 20 21, highest: 52 54 56 57 61
## --------------------------------------------------------------------------------
## genero
## n missing distinct
## 237 0 2
##
## Value FEMENINO MASCULINO
## Frequency 140 97
## Proportion 0.591 0.409
## --------------------------------------------------------------------------------
## fecha_alta
## n missing distinct
## 237 0 137
##
## lowest : 01/02/22 01/07/22 01/10/21 01/12/21 02/02/22
## highest: 29/03/22 29/04/22 29/08/20 30/07/22 31/05/21
## --------------------------------------------------------------------------------
## motivo_baja
## n missing distinct
## 237 0 5
##
## lowest : ABANDONO BAJA POR FALTAS JUBILACION RENUNCIA VOLUNTARIA TERMINO DE CONTRATO
## highest: ABANDONO BAJA POR FALTAS JUBILACION RENUNCIA VOLUNTARIA TERMINO DE CONTRATO
##
## Value ABANDONO BAJA POR FALTAS JUBILACION
## Frequency 1 141 1
## Proportion 0.004 0.595 0.004
##
## Value RENUNCIA VOLUNTARIA TERMINO DE CONTRATO
## Frequency 86 8
## Proportion 0.363 0.034
## --------------------------------------------------------------------------------
## dias_laborados
## n missing distinct Info Mean Gmd .05 .10
## 237 0 95 1 83.42 128.2 1.0 3.0
## .25 .50 .75 .90 .95
## 9.0 21.0 49.0 148.4 377.0
##
## lowest : 0 1 2 3 4, highest: 1059 1236 1408 1429 1966
## --------------------------------------------------------------------------------
## fecha_baja
## n missing distinct
## 237 0 95
##
## lowest : 01/02/22 01/03/22 01/08/22 02/05/22 03/03/22
## highest: 29/06/22 29/07/22 30/06/22 30/07/22 31/01/22
## --------------------------------------------------------------------------------
## puesto
## n missing distinct
## 237 0 31
##
## lowest : ANALISTA DE NOMINAS /AUX DE R.H. AUXILIAR DE EMBARQUES AY. GENERAL AY.GENERAL (MATERIALES) AYUD.EMBARQUES
## highest: PRACTICANTE DE MTTO RESIDENTE RESIDENTE YANFENG SERVICIO AL CLIENTE SOLDADOR
## --------------------------------------------------------------------------------
## sal_imss
## n missing distinct Info Mean Gmd
## 237 0 9 0.515 178.6 11.11
##
## lowest : 144.45 151.61 151.67 176.72 180.68, highest: 180.68 182.68 183.68 338.36 500.00
##
## Value 144.45 151.61 151.67 176.72 180.68 182.68 183.68 338.36 500.00
## Frequency 1 28 2 15 186 2 1 1 1
## Proportion 0.004 0.118 0.008 0.063 0.785 0.008 0.004 0.004 0.004
## --------------------------------------------------------------------------------
## colonia
## n missing distinct
## 237 0 98
##
## lowest : ACANTO RESIDENCIAL ALAMOS DEL PARQUE ALBERTA ESCAMILLA ANALCO II ANALCO PONIENTE
## highest: VILLAS DE SAN CARLOS VILLAS DE SAN JOSE VILLAS DEL ORIENTE VILLAS REGINA VISTAS DEL RIO
## --------------------------------------------------------------------------------
## municipio
## n missing distinct
## 237 0 13
##
## lowest : APODACA CADEREYTA CIENEGA DE FLORES GUADALUPE JUAREZ
## highest: SALTILLO SAN NICOLAS DE LOS G SAN NICOLAS DE LOS GARZA SAN PDRO COAH ZUAZUA
## --------------------------------------------------------------------------------
## estado
## n missing distinct
## 237 0 3
##
## Value COAHUILA NUEVO LEÓN SALTILLO
## Frequency 9 227 1
## Proportion 0.038 0.958 0.004
## --------------------------------------------------------------------------------
## estado_civil
## n missing distinct
## 237 0 5
##
## lowest : CASADO DIVORCIADO SOLTERO Unión libre UNIÓN LIBRE
## highest: CASADO DIVORCIADO SOLTERO Unión libre UNIÓN LIBRE
##
## Value CASADO DIVORCIADO SOLTERO Unión libre UNIÓN LIBRE
## Frequency 64 3 110 1 59
## Proportion 0.270 0.013 0.464 0.004 0.249
## --------------------------------------------------------------------------------
RHBAJAS1<-RHBAJAS
RHBAJAS1<-subset(RHBAJAS1,select = -c(genero,fecha_alta,motivo_baja,puesto,estado,nombre,colonia,municipio,fecha_baja))
summary(RHBAJAS1)## edad dias_laborados sal_imss estado_civil
## Min. : 0.00 Min. : 0.00 Min. :144.4 Length:237
## 1st Qu.:23.00 1st Qu.: 9.00 1st Qu.:180.7 Class :character
## Median :29.00 Median : 21.00 Median :180.7 Mode :character
## Mean :30.52 Mean : 83.42 Mean :178.6
## 3rd Qu.:37.00 3rd Qu.: 49.00 3rd Qu.:180.7
## Max. :61.00 Max. :1966.00 Max. :500.0
Eliminamos dos reglones que tenian como edad (0)
RHBAJAS2 <- RHBAJAS1
RHBAJAS2 <- RHBAJAS2 [RHBAJAS2$edad> min(1), ]
summary(RHBAJAS2)## edad dias_laborados sal_imss estado_civil
## Min. :18.00 Min. : 0.00 Min. :144.4 Length:235
## 1st Qu.:23.00 1st Qu.: 9.50 1st Qu.:180.7 Class :character
## Median :29.00 Median : 21.00 Median :180.7 Mode :character
## Mean :30.78 Mean : 84.07 Mean :178.6
## 3rd Qu.:37.00 3rd Qu.: 49.50 3rd Qu.:180.7
## Max. :61.00 Max. :1966.00 Max. :500.0
RH_EDAD_NORM<-scale(RHBAJAS2[1:2])fviz_nbclust(RH_EDAD_NORM, kmeans, method="wss")+
geom_vline(xintercept=4, linetype=2)+
labs(subtitle = "Elbow method") RHEDAD_Cluster1<-kmeans(RH_EDAD_NORM,4)
RHEDAD_Cluster1## K-means clustering with 4 clusters of sizes 43, 107, 5, 80
##
## Cluster means:
## edad dias_laborados
## 1 1.6031879 -0.11611923
## 2 -0.8512555 -0.17238996
## 3 1.2245019 5.86438920
## 4 0.2003094 -0.07353867
##
## Clustering vector:
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## 4 4 2 2 4 1 4 4 1 2 2 4 2 4 4 2 2 2 2 2
## 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
## 4 3 2 4 1 2 4 2 2 2 4 2 2 2 4 2 2 4 4 2
## 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
## 2 2 2 2 2 2 2 2 1 1 1 1 4 1 2 2 1 2 2 3
## 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
## 2 2 4 2 2 1 2 2 4 2 2 2 4 2 4 2 4 2 2 1
## 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 98 99 100 101
## 3 2 2 4 1 2 1 2 2 2 4 1 1 2 2 4 1 4 2 4
## 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
## 2 2 1 4 2 2 4 3 4 4 2 4 4 2 4 4 4 1 1 1
## 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
## 2 2 2 2 2 4 2 4 1 2 4 2 1 2 4 2 4 1 4 1
## 142 143 144 145 146 147 148 150 151 152 153 154 155 156 157 158 159 160 161 162
## 4 4 1 1 1 2 4 4 4 2 2 2 4 1 1 2 4 2 4 1
## 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
## 1 1 1 4 1 2 2 4 2 2 1 4 1 2 1 4 4 1 4 4
## 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
## 2 2 2 4 1 3 4 2 2 4 4 4 4 4 4 4 4 2 4 4
## 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
## 4 4 2 4 1 4 2 2 2 1 2 2 2 4 4 2 2 4 4 4
## 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
## 2 2 4 2 2 2 4 1 4 1 2 2 2 2 2
##
## Within cluster sum of squares by cluster:
## [1] 19.40753 15.18543 18.67351 39.82387
## (between_SS / total_SS = 80.1 %)
##
## Available components:
##
## [1] "cluster" "centers" "totss" "withinss" "tot.withinss"
## [6] "betweenss" "size" "iter" "ifault"
fviz_cluster(RHEDAD_Cluster1,data=RH_EDAD_NORM)RHBAJAS3 <- RHBAJAS2
RHBAJAS3$Clusters<-RHEDAD_Cluster1$cluster
RHBAJAS4<-RHBAJAS3 %>% group_by(Clusters) %>% summarise(edad=max(edad)) %>% arrange(desc(edad))
RHBAJAS3$Cluster_Names<-factor(RHBAJAS3$Clusters,levels = c(1,2,3,4),
labels=c("Adulto", "Principiante", "Mayor", "Juvenil"))RHBAJAS6 <- RHBAJAS3 %>% group_by(Cluster_Names) %>% dplyr:: summarize(edad_años=max(edad),
dias_laborados=mean(dias_laborados),
Count=n())clusters<-as.data.frame(RHBAJAS6)
clusters## Cluster_Names edad_años dias_laborados Count
## 1 Adulto 57 57.62791 43
## 2 Principiante 27 44.81308 107
## 3 Mayor 61 1419.60000 5
## 4 Juvenil 39 67.32500 80
ggplot(RHBAJAS6,aes(x=reorder(Cluster_Names,Count),y=Count,fill=Cluster_Names)) +
geom_bar(stat="identity")ggplot(RHBAJAS6, aes(x=Cluster_Names,y=edad_años,fill= Cluster_Names,label=round(edad_años,digits=2))) +
geom_col() +
geom_text()ggplot(RHBAJAS6,aes(x=Cluster_Names,y=dias_laborados,fill= Cluster_Names,label=round(dias_laborados,digits=2))) +
geom_col() +
geom_text()ggplot(RHBAJAS3, aes(x=Cluster_Names, y=edad, fill=Cluster_Names)) +
geom_boxplot()+
ggtitle("Edad (Dispersion)")Durante esta actividad realizamos un análisis en la base de datos de Recursos Humanos, enfocados en las variables de Edad, Salario y Días Trabajados, por lo que se decidió definir varios pasos a seguir para llegar al objetivo deseado que era finalmente llegar a la construcción de los clusters.
Tomando en cuenta los hallazgos de la edad y el salario diario, se llego a la conclusión de lo siguiente:
Hay más bajas de adultos con el rango de edades de 41 a 61, el cuál se identifico como jubilación.
Los adultos de 33-40 años ganan más con un sueldo diario de 186.16 en promedio.
De igual manera podemos observar cuatro Clusters que toman en cuenta la edad y los días laborados:
El grupo que cuenta con más días laborados es el de edad máxima,
siendo los adultos, de igual manera estos cuentan con un salario
mayor.
Por último podemos observar que en los gráficos que se analizan con
estas variables tenemos los siguientes puntos a consideración:
- Edad Máxima
- Días Laborados Máximos
- Recuento de los grupos que presentan mayor actividad en la
empresa.
- La dispersión de edad que existe entre cada uno de los grupos.
En base a todo el análisis que se realizó previamente se puede observar lo siguiente;
Se recomienda que se consideren los siguientes indicadores.
Para el departamento de Recursos Humanos;
1. Nivel de satisfacción de los empleados
El nivel de agrado que los trabajadores tienen con su empleo, tomando en cuenta la compensación laboral, carga de trabajo, percepciones de la administración, flexibilidad, trabajo en equipo, manejo de recursos, etc. Generalmente, se mide en base a entrevistas para conocer lo bueno y lo malo.
2. Tiempo medio de contratación
El tiempo medio de contratación es el número de días que pasan desde que se publica la oferta hasta que el nuevo empleado se incorpora a la empresa.
En cada proceso de selección, cuántos días pasan entre la publicación de la vacante y la contratación para después calcular el promedio de la empresa.
Para el departamento de Entregas;
1. Nivel de cumplimiento de entregas a tiempo
Tomando en cuenta que para diversos clientes no existen retardos y para otros si, es indispensable conocer el nivel de cumplimiento de entregas a tiempo de la empresa, que se resume en un porcentaje que puede ser brindado para los futuros clientes cómo información extra que puede ser solicitada.
Formula –> Cumplimiento de entregas a tiempo = (Entregas tardías / Entregas programadas) x 100
Para el departamento de Producción;
1. Tiempo de transición
El tiempo de transición representa la cantidad de tiempo necesario para pasar de una tarea a otra, normalmente representa el tiempo perdido durante el cambio de un producto a otro en una línea de producción.
Formula –> Tiempo de transición = Tiempo disponible neto – Tiempo de producción
2. Promedio de perdida de stock
El stock que se pierde o queda obsoleto en el almacén durante un periodo concreto. Este valor indica al responsable cómo es la gestión del stock, la eficiencia de los operarios o las condiciones de almacenaje en la instalación, entre otras cuestiones.
Formula –> Pérdida de stock = (cantidad no suministrada / cantidad solicitada) x 100