rhdata <- read.csv("/Users/mac/Downloads/RHDATA.csv")
summary (rhdata)## No..De.Empleado APELLIDOS NOMBRE AÑO.NACIMIENTO
## Min. : 1.00 Length:122 Length:122 Min. :1949
## 1st Qu.: 24.75 Class :character Class :character 1st Qu.:1977
## Median : 48.50 Mode :character Mode :character Median :1989
## Mean : 56.88 Mean :1986
## 3rd Qu.: 82.00 3rd Qu.:1997
## Max. :148.00 Max. :2022
## NA's :30 NA's :9
## GENERO.ID GENERO RFC AÑO.DE.ALTA
## Min. :1.000 Length:122 Length:122 Min. :2010
## 1st Qu.:1.000 Class :character Class :character 1st Qu.:2020
## Median :1.000 Mode :character Mode :character Median :2022
## Mean :1.451 Mean :2021
## 3rd Qu.:2.000 3rd Qu.:2022
## Max. :2.000 Max. :2022
## NA's :9 NA's :10
## Primer.mes X4to.mes BAJA PUESTO.ID
## Min. :2000 Min. :2010 Min. :3 Min. : 0.000
## 1st Qu.:2020 1st Qu.:2020 1st Qu.:3 1st Qu.: 3.000
## Median :2022 Median :2022 Median :3 Median : 3.000
## Mean :2020 Mean :2021 Mean :3 Mean : 6.575
## 3rd Qu.:2022 3rd Qu.:2022 3rd Qu.:3 3rd Qu.: 6.000
## Max. :2022 Max. :2022 Max. :3 Max. :24.000
## NA's :11 NA's :11 NA's :109 NA's :9
## PUESTO DEPARTAMENTO NO.SEGURO.SOCIAL SALARIO.DIARIO.IMSS
## Length:122 Length:122 Length:122 Min. :144.4
## Class :character Class :character Class :character 1st Qu.:176.7
## Mode :character Mode :character Mode :character Median :180.7
## Mean :179.1
## 3rd Qu.:180.7
## Max. :337.1
## NA's :9
## FACTOR.CRED.INFONAVIT N..CREDITO.INFONAVIT LUGAR.DE.NACIMIENTO
## Length:122 Length:122 Length:122
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## CURP CALLE NUMERO.INTERNO COLONIA
## Length:122 Length:122 Length:122 Length:122
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## MUNICIPIO ESTADO CODIGO.POSTAL ESTADO.CIVIL
## Length:122 Length:122 Min. :25016 Length:122
## Class :character Class :character 1st Qu.:66640 Class :character
## Mode :character Mode :character Median :66646 Mode :character
## Mean :63365
## 3rd Qu.:66649
## Max. :67493
## NA's :9
## TARJETA....CUENTA X X.1
## Length:122 Mode:logical Mode:logical
## Class :character NA's:122 NA's:122
## Mode :character
##
##
##
##
# install.packages("tidyverse")
library(tidyverse)## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.0 ✔ stringr 1.4.1
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
# install.packages("janitor")
library(janitor)##
## Attaching package: 'janitor'
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
tabyl(rhdata, PUESTO, GENERO)## PUESTO FEMENINO MASCULINO emptystring_
## 0 0 9
## AYUDANTE DE MANTENIMIENTO 0 1 0
## Ayudante general 0 1 0
## AYUDANTE GENERAL 43 23 0
## CHOFER 0 4 0
## CHOFER GESTOR 0 1 0
## COSTURERA 9 1 0
## CUSTOMER SERVICE INF 0 1 0
## ENFERMERA 1 0 0
## Externo 0 1 0
## EXTERNO 0 1 0
## GESTOR 0 1 0
## GUARDIA DE SEGURIDAD 0 1 0
## INSPECTOR DE CALIDAD 2 0 0
## LIDER 1 0 0
## LIMPIEZA 1 0 0
## MANTENIMIENTO 0 1 0
## MONTACARGUISTA 0 1 0
## MOZO 0 1 0
## OP. FLEXO-RANURADORA-REFILADORA 0 1 0
## OPERADOR SIERRA 0 1 0
## PINTOR 0 1 0
## RECIBO 1 0 0
## RESIDENTE 0 4 0
## SOLDADOR 0 5 0
## Supervisor de Máquin 0 1 0
## Supervisor de pegado 1 0 0
## SUPERVISORA 2 0 0
library(psych)##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
describe(rhdata)## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## vars n mean sd median trimmed mad
## No..De.Empleado 1 92 56.88 40.06 48.50 53.68 40.77
## APELLIDOS* 2 122 51.30 33.32 49.50 50.88 42.25
## NOMBRE* 3 122 51.33 33.13 51.50 51.14 42.25
## AÑO.NACIMIENTO 4 113 1986.11 13.41 1989.00 1986.78 14.83
## GENERO.ID 5 113 1.45 0.50 1.00 1.44 0.00
## GENERO* 6 122 2.35 0.62 2.00 2.41 0.74
## RFC* 7 122 53.80 34.89 53.50 53.50 45.22
## AÑO.DE.ALTA 8 112 2020.56 2.53 2022.00 2021.18 0.00
## Primer.mes 9 111 2020.49 3.08 2022.00 2021.21 0.00
## X4to.mes 10 111 2020.79 2.35 2022.00 2021.39 0.00
## BAJA 11 13 3.00 0.00 3.00 3.00 0.00
## PUESTO.ID 12 113 6.58 6.44 3.00 5.29 0.00
## PUESTO* 13 122 7.92 7.52 4.00 6.55 0.00
## DEPARTAMENTO* 14 122 8.58 7.87 6.00 7.96 7.41
## NO.SEGURO.SOCIAL* 15 122 52.87 34.78 52.50 52.50 45.22
## SALARIO.DIARIO.IMSS 16 113 179.06 24.29 180.68 177.00 0.00
## FACTOR.CRED.INFONAVIT* 17 122 3.91 2.44 6.00 4.01 0.00
## N..CREDITO.INFONAVIT* 18 122 3.91 2.44 6.00 4.01 0.00
## LUGAR.DE.NACIMIENTO* 19 122 14.34 13.52 11.00 13.22 14.83
## CURP* 20 122 53.80 34.89 53.50 53.50 45.22
## CALLE* 21 122 50.00 31.74 50.50 49.88 40.03
## NUMERO.INTERNO* 22 122 31.38 26.87 28.50 29.62 40.03
## COLONIA* 23 122 37.52 21.63 43.50 38.04 21.50
## MUNICIPIO* 24 122 3.39 2.39 2.00 3.01 0.00
## ESTADO* 25 122 4.73 1.38 5.00 5.00 0.00
## CODIGO.POSTAL 26 113 63364.74 11201.89 66646.00 66622.84 4.45
## ESTADO.CIVIL* 27 122 3.20 1.29 4.00 3.21 1.48
## TARJETA....CUENTA* 28 122 2.02 0.42 2.00 2.00 0.00
## X 29 0 NaN NA NA NaN NA
## X.1 30 0 NaN NA NA NaN NA
## min max range skew kurtosis se
## No..De.Empleado 1.00 148.00 147.0 0.60 -0.67 4.18
## APELLIDOS* 1.00 110.00 109.0 0.08 -1.24 3.02
## NOMBRE* 1.00 108.00 107.0 0.01 -1.28 3.00
## AÑO.NACIMIENTO 1949.00 2022.00 73.0 -0.37 -0.47 1.26
## GENERO.ID 1.00 2.00 1.0 0.19 -1.98 0.05
## GENERO* 1.00 3.00 2.0 -0.38 -0.70 0.06
## RFC* 1.00 114.00 113.0 0.04 -1.27 3.16
## AÑO.DE.ALTA 2010.00 2022.00 12.0 -2.35 5.44 0.24
## Primer.mes 2000.00 2022.00 22.0 -3.65 17.55 0.29
## X4to.mes 2010.00 2022.00 12.0 -2.57 6.81 0.22
## BAJA 3.00 3.00 0.0 NaN NaN 0.00
## PUESTO.ID 0.00 24.00 24.0 1.54 0.86 0.61
## PUESTO* 1.00 28.00 27.0 1.51 0.80 0.68
## DEPARTAMENTO* 1.00 22.00 21.0 0.41 -1.51 0.71
## NO.SEGURO.SOCIAL* 1.00 113.00 112.0 0.05 -1.28 3.15
## SALARIO.DIARIO.IMSS 144.45 337.05 192.6 3.42 17.64 2.28
## FACTOR.CRED.INFONAVIT* 1.00 6.00 5.0 -0.33 -1.88 0.22
## N..CREDITO.INFONAVIT* 1.00 6.00 5.0 -0.33 -1.88 0.22
## LUGAR.DE.NACIMIENTO* 1.00 42.00 41.0 0.40 -1.35 1.22
## CURP* 1.00 114.00 113.0 0.04 -1.27 3.16
## CALLE* 1.00 105.00 104.0 -0.01 -1.25 2.87
## NUMERO.INTERNO* 1.00 80.00 79.0 0.29 -1.36 2.43
## COLONIA* 1.00 74.00 73.0 -0.31 -1.17 1.96
## MUNICIPIO* 1.00 10.00 9.0 1.24 0.22 0.22
## ESTADO* 1.00 6.00 5.0 -1.71 1.93 0.12
## CODIGO.POSTAL 25016.00 67493.00 42477.0 -3.06 7.42 1053.79
## ESTADO.CIVIL* 1.00 5.00 4.0 -0.11 -1.43 0.12
## TARJETA....CUENTA* 1.00 3.00 2.0 0.17 2.70 0.04
## X Inf -Inf -Inf NA NA NA
## X.1 Inf -Inf -Inf NA NA NA
str(rhdata)## 'data.frame': 122 obs. of 30 variables:
## $ No..De.Empleado : int 1 2 3 4 5 6 7 8 9 10 ...
## $ APELLIDOS : chr "MARTINEZ DE LOERA" "DE LEON MORENO" "HERNANDEZ CERVANTES" "CAZARES MORALES" ...
## $ NOMBRE : chr "NICOLAS" "MARIANA" "JOSE LUIS" "MARIA" ...
## $ AÑO.NACIMIENTO : int 1955 1979 1949 1990 1965 1984 1967 1996 1995 1985 ...
## $ GENERO.ID : int 1 2 1 1 1 2 1 2 2 1 ...
## $ GENERO : chr "MASCULINO" "FEMENINO" "MASCULINO" "FEMENINO" ...
## $ RFC : chr "MALN550910338" "LEMM7905148GA" "HECL4911213X3" "CAMM9005019S8" ...
## $ AÑO.DE.ALTA : int 2010 2011 2011 2013 2014 2014 2015 2016 2017 2017 ...
## $ Primer.mes : int 2010 2011 NA 2013 2014 2014 2015 2016 2017 2017 ...
## $ X4to.mes : int 2010 2011 NA 2013 2014 2014 2015 2016 2017 2017 ...
## $ BAJA : int NA NA NA NA NA NA NA NA NA NA ...
## $ PUESTO.ID : int 23 22 0 24 24 7 6 3 3 6 ...
## $ PUESTO : chr "Supervisor de Máquin" "Supervisor de pegado" "Externo" "SUPERVISORA" ...
## $ DEPARTAMENTO : chr "Produccion Cartón MDL" "Produccion Cartón MDL" "Externo" "Produccion Cartón MC" ...
## $ NO.SEGURO.SOCIAL : chr "43745527937" "43127902955" "2184909675" "43089001317" ...
## $ SALARIO.DIARIO.IMSS : num 177 177 177 337 177 ...
## $ FACTOR.CRED.INFONAVIT: chr "" "" "" "" ...
## $ N..CREDITO.INFONAVIT : chr "" "" "" "" ...
## $ LUGAR.DE.NACIMIENTO : chr "" "" "" "" ...
## $ CURP : chr "MALN550910HZSRRC09" "LEMM790514MCLNRR09" "HECL491121HJCRRS04" "CAMM900501MVZZRR00" ...
## $ CALLE : chr "JOSE I LUGO" "44682" "HACIENDA SAN CRISTOBAL" "RIO ACAPONETA" ...
## $ NUMERO.INTERNO : chr "" "115" "" "" ...
## $ COLONIA : chr "UNIDAD LABORAL" "SANTA TERESITA" "VILLAS DE HUINALA" "PUEBLO NUEVO" ...
## $ MUNICIPIO : chr "SAN NICOLAS DE LOS G" "APODACA" "APODACA" "APODACA" ...
## $ ESTADO : chr "Nuevo León" "Nuevo León" "Nuevo León" "Nuevo León" ...
## $ CODIGO.POSTAL : int 66440 66605 66634 66649 66620 25016 66633 66649 25290 66473 ...
## $ ESTADO.CIVIL : chr "Soltero" "Soltero" "Soltero" "Casado" ...
## $ TARJETA....CUENTA : chr "BANORTE" "BANORTE" "BANORTE" "BANORTE" ...
## $ X : logi NA NA NA NA NA NA ...
## $ X.1 : logi NA NA NA NA NA NA ...
Variable<-c("`No..De.Empleado`","`APELLIDOS`","`NOMBRE`","`AÑO.NACIMIENTO`","`GENERO`","`RFC`","`AÑO.DE.ALTA`","`Primer.mes`","`X4to.mes`","`BAJA`","`PUESTO`","`DEPARTAMENTO`","`NO.SEGURO.SOCIAL`","`SALARIO.DIARIO.IMSS`","`FACTOR.CRED.INFONAVIT`","`N..CREDITO.INFONAVIT`","`LUGAR.DE.NACIMIENTO`","`CURP`","`CALLE`","`NUMERO.INTERNO`","`COLONIA`","`MUNICIPIO`","`ESTADO`","`CODIGO.POSTAL`","`ESTADO.CIVIL`","`TARJETA....CUENTA `")
Type<-c("cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cuantitativa (discreta)", "cuantitativa (discreta)", "cuantitativa (discreta)", "cuantitativa (discreta)", "cualitativa (nominal)", "cualitativa (nominal)", "cuantitativa (discreta)", "cuantitativa (discreta)", "cuantitativa (discreta)", "cuantitativa (discreta)", "cualitativa (nominal)", "cualitativa (nominal)","cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativa (nominal)", "cualitativo (nominal)", "cualitativo (nominal)", "cualitativo (nominal)")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
No..De.Empleado |
cualitativa (nominal) |
APELLIDOS |
cualitativa (nominal) |
NOMBRE |
cualitativa (nominal) |
AÑO.NACIMIENTO |
cualitativa (nominal) |
GENERO |
cualitativa (nominal) |
RFC |
cualitativa (nominal) |
AÑO.DE.ALTA |
cuantitativa (discreta) |
Primer.mes |
cuantitativa (discreta) |
X4to.mes |
cuantitativa (discreta) |
BAJA |
cuantitativa (discreta) |
PUESTO |
cualitativa (nominal) |
DEPARTAMENTO |
cualitativa (nominal) |
NO.SEGURO.SOCIAL |
cuantitativa (discreta) |
SALARIO.DIARIO.IMSS |
cuantitativa (discreta) |
FACTOR.CRED.INFONAVIT |
cuantitativa (discreta) |
N..CREDITO.INFONAVIT |
cuantitativa (discreta) |
LUGAR.DE.NACIMIENTO |
cualitativa (nominal) |
CURP |
cualitativa (nominal) |
CALLE |
cualitativa (nominal) |
NUMERO.INTERNO |
cualitativa (nominal) |
COLONIA |
cualitativa (nominal) |
MUNICIPIO |
cualitativa (nominal) |
ESTADO |
cualitativa (nominal) |
CODIGO.POSTAL |
cualitativo (nominal) |
ESTADO.CIVIL |
cualitativo (nominal) |
TARJETA....CUENTA |
cualitativo (nominal) |
Variable<-c("`No..De.Empleado`","`APELLIDOS`","`NOMBRE`","`AÑO.NACIMIENTO`","`GENERO`","`RFC`","`AÑO.DE.ALTA`","`Primer.mes`","`X4to.mes`","`BAJA`","`PUESTO`","`DEPARTAMENTO`","`NO.SEGURO.SOCIAL`","`SALARIO.DIARIO.IMSS`","`FACTOR.CRED.INFONAVIT`","`N..CREDITO.INFONAVIT`","`LUGAR.DE.NACIMIENTO`","`CURP`","`CALLE`","`NUMERO.INTERNO`","`COLONIA`","`MUNICIPIO`","`ESTADO`","`CODIGO.POSTAL`","`ESTADO.CIVIL`","`TARJETA....CUENTA `")
Tipo_medicion <- c("N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "MXN PESO", "MXN PESO", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A")
table<-data.frame(Variable,Tipo_medicion)
knitr::kable(table)| Variable | Tipo_medicion |
|---|---|
No..De.Empleado |
N/A |
APELLIDOS |
N/A |
NOMBRE |
N/A |
AÑO.NACIMIENTO |
N/A |
GENERO |
N/A |
RFC |
N/A |
AÑO.DE.ALTA |
N/A |
Primer.mes |
N/A |
X4to.mes |
N/A |
BAJA |
N/A |
PUESTO |
N/A |
DEPARTAMENTO |
N/A |
NO.SEGURO.SOCIAL |
N/A |
SALARIO.DIARIO.IMSS |
MXN PESO |
FACTOR.CRED.INFONAVIT |
MXN PESO |
N..CREDITO.INFONAVIT |
N/A |
LUGAR.DE.NACIMIENTO |
N/A |
CURP |
N/A |
CALLE |
N/A |
NUMERO.INTERNO |
N/A |
COLONIA |
N/A |
MUNICIPIO |
N/A |
ESTADO |
N/A |
CODIGO.POSTAL |
N/A |
ESTADO.CIVIL |
N/A |
TARJETA....CUENTA |
N/A |
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, FACTOR.CRED.INFONAVIT, N..CREDITO.INFONAVIT,X, X.1, No..De.Empleado, RFC, LUGAR.DE.NACIMIENTO, CURP, CALLE, NUMERO.INTERNO, COLONIA, TARJETA....CUENTA ))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] 77
¿Cuántos NA tengo por variable?
sapply(rhdata, function(x) sum (is.na(x)))## APELLIDOS NOMBRE AÑO.NACIMIENTO GENERO.ID
## 0 0 9 9
## GENERO AÑO.DE.ALTA Primer.mes X4to.mes
## 0 10 11 11
## PUESTO.ID PUESTO DEPARTAMENTO NO.SEGURO.SOCIAL
## 9 0 0 0
## SALARIO.DIARIO.IMSS MUNICIPIO ESTADO CODIGO.POSTAL
## 9 0 0 9
## ESTADO.CIVIL
## 0
Borrar todos los registros NA de una tabla
rhdata <- na.omit(rhdata)
summary(rhdata)## APELLIDOS NOMBRE AÑO.NACIMIENTO GENERO.ID
## Length:110 Length:110 Min. :1955 Min. :1.000
## Class :character Class :character 1st Qu.:1977 1st Qu.:1.000
## Mode :character Mode :character Median :1989 Median :1.000
## Mean :1986 Mean :1.455
## 3rd Qu.:1997 3rd Qu.:2.000
## Max. :2022 Max. :2.000
## GENERO AÑO.DE.ALTA Primer.mes X4to.mes
## Length:110 Min. :2010 Min. :2010 Min. :2010
## Class :character 1st Qu.:2020 1st Qu.:2020 1st Qu.:2020
## Mode :character Median :2022 Median :2022 Median :2022
## Mean :2021 Mean :2021 Mean :2021
## 3rd Qu.:2022 3rd Qu.:2022 3rd Qu.:2022
## Max. :2022 Max. :2022 Max. :2022
## PUESTO.ID PUESTO DEPARTAMENTO NO.SEGURO.SOCIAL
## Min. : 1.000 Length:110 Length:110 Length:110
## 1st Qu.: 3.000 Class :character Class :character Class :character
## Median : 3.000 Mode :character Mode :character Mode :character
## Mean : 6.727
## 3rd Qu.: 6.000
## Max. :24.000
## SALARIO.DIARIO.IMSS MUNICIPIO ESTADO CODIGO.POSTAL
## Min. :144.4 Length:110 Length:110 Min. :25016
## 1st Qu.:176.7 Class :character Class :character 1st Qu.:66643
## Median :180.7 Mode :character Mode :character Median :66646
## Mean :179.3 Mean :63288
## 3rd Qu.:180.7 3rd Qu.:66649
## Max. :337.1 Max. :67493
## ESTADO.CIVIL
## Length:110
## Class :character
## Mode :character
##
##
##
sum(is.na(rhdata))## [1] 0
Para poder trabajar bien con una base de datos y que los resultados que salgan de los análisis sean confiables y asertivos, se necesita realizar una limpieza de la base ya sea desde excel, desde R Studio e inclusive desde las dos como fue el caso. Para esta base de datos se necesito cambiar el formato de la fecha desde la base de datos, esto debido a que el lenguaje de la fecha estaba en dos idiomas, en ingles y español, por lo tanto era imposible cambiar la fecha puesto que no se sabÃa si era dÃa o mes. Para resolver este problema, se usarón unicamente los años para asà no alterar los resultados y poder tener resultados confiables.
Medidas de Tendencia Central: Permiten conocer el valor al que tiende el conjunto de datos.
Media o Promedio: Valor que se obtiene al sumar todos los datos y dividirlos entre la cantidad total de datos.
media_rhdata <- mean(rhdata$SALARIO.DIARIO.IMSS)
media_rhdata## [1] 179.3115
Mediana: Valor que ocupa el lugar central de todos los datos cuando estos estan ordenados de menor a mayor.
mediana_rhdata<- median(rhdata$SALARIO.DIARIO.IMSS)
mediana_rhdata ## [1] 180.68
Moda: Valor que aparece con mayor frecuencia en un conjunto de datos. ### Moda
mode <- function (x) {
ux <- unique(x)
ux [which.max(tabulate(match(x,ux)))]
}
mode_rhdata <- mode(rhdata$SALARIO.DIARIO.IMSS)
mode_rhdata## [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(rhdata$SALARIO.DIARIO.IMSS)
La variable de “SALARIO.DIARIO.IMSS tiene un SESGO
POSITIVO
MEDIDAS DE DISPERSION: Miden que tan esparcidos se encuentran los datos.
Rango: Intervalo o diferencia entre el valor maximo y el minimo de un conjunto de datos
rango_rhdata <- max(rhdata$SALARIO.DIARIO.IMSS) - min (rhdata$SALARIO.DIARIO.IMSS)
rango_rhdata ## [1] 192.6
r<- range(rhdata$SALARIO.DIARIO.IMSS)
r ## [1] 144.45 337.05
varianza_rhdata <- var(rhdata$SALARIO.DIARIO.IMSS)
varianza_rhdata## [1] 599.0348
Desviacion Estandar: RaÃz cuadrada de la varianza
desviacion_estandar_rhdata <- sqrt(varianza_rhdata)
desviacion_estandar_rhdata ## [1] 24.47519
summary(rhdata)## APELLIDOS NOMBRE AÑO.NACIMIENTO GENERO.ID
## Length:110 Length:110 Min. :1955 Min. :1.000
## Class :character Class :character 1st Qu.:1977 1st Qu.:1.000
## Mode :character Mode :character Median :1989 Median :1.000
## Mean :1986 Mean :1.455
## 3rd Qu.:1997 3rd Qu.:2.000
## Max. :2022 Max. :2.000
## GENERO AÑO.DE.ALTA Primer.mes X4to.mes
## Length:110 Min. :2010 Min. :2010 Min. :2010
## Class :character 1st Qu.:2020 1st Qu.:2020 1st Qu.:2020
## Mode :character Median :2022 Median :2022 Median :2022
## Mean :2021 Mean :2021 Mean :2021
## 3rd Qu.:2022 3rd Qu.:2022 3rd Qu.:2022
## Max. :2022 Max. :2022 Max. :2022
## PUESTO.ID PUESTO DEPARTAMENTO NO.SEGURO.SOCIAL
## Min. : 1.000 Length:110 Length:110 Length:110
## 1st Qu.: 3.000 Class :character Class :character Class :character
## Median : 3.000 Mode :character Mode :character Mode :character
## Mean : 6.727
## 3rd Qu.: 6.000
## Max. :24.000
## SALARIO.DIARIO.IMSS MUNICIPIO ESTADO CODIGO.POSTAL
## Min. :144.4 Length:110 Length:110 Min. :25016
## 1st Qu.:176.7 Class :character Class :character 1st Qu.:66643
## Median :180.7 Mode :character Mode :character Median :66646
## Mean :179.3 Mean :63288
## 3rd Qu.:180.7 3rd Qu.:66649
## Max. :337.1 Max. :67493
## ESTADO.CIVIL
## Length:110
## Class :character
## Mode :character
##
##
##
plot(rhdata$SALARIO.DIARIO.IMSS, rhdata$AÑO.NACIMIENTO,main="Relación de variables", xlab="Salario (MXN PESO)",ylab="Año de nacimiento")Variable<-c("`Externo`","`LÃder`","`Ayudante de Mantenimiento`","`Ayudante General`","`Chofer`","`Chofer Gestor`","`Costurera`","`Customer Service Inf`","`Enfermera`","`Gestor`","`Guardia de seguridad`","`Inspector de Calidad`","`Limpieza`","`Mantenimiento`","`Montacarguista`","`Mozo`","`Op. Flexo-Ranuradura-Refiladora`","`Operador Sierra`","`Pintor`","`Recibo`","`Residente`","`Soldador`","`Supervisor de pegado`","`Supervisor de maquin`","`Supervisora`")
Type<-c("0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18","19", "20", "21", "22", "23", "24")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
Externo |
0 |
LÃder |
1 |
Ayudante de Mantenimiento |
2 |
Ayudante General |
3 |
Chofer |
4 |
Chofer Gestor |
5 |
Costurera |
6 |
Customer Service Inf |
7 |
Enfermera |
8 |
Gestor |
9 |
Guardia de seguridad |
10 |
Inspector de Calidad |
11 |
Limpieza |
12 |
Mantenimiento |
13 |
Montacarguista |
14 |
Mozo |
15 |
Op. Flexo-Ranuradura-Refiladora |
16 |
Operador Sierra |
17 |
Pintor |
18 |
Recibo |
19 |
Residente |
20 |
Soldador |
21 |
Supervisor de pegado |
22 |
Supervisor de maquin |
23 |
Supervisora |
24 |
ggplot(rhdata, aes(x=PUESTO.ID, y=SALARIO.DIARIO.IMSS)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() + # Add bars to the plot
labs(title = "Relación de Puesto y Genero", # Add a title
subtitle = "RH empresa FORM", # Add a subtitle
caption = "Relación", # Add a caption
x = "Puesto")count(rhdata, ESTADO.CIVIL, sort=TRUE)## ESTADO.CIVIL n
## 1 Soltero 44
## 2 Casado 43
## 3 Unión Libre 20
## 4 Divorciado 3
ggplot(rhdata, aes(x=media_rhdata, y=ESTADO.CIVIL)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() + # Add bars to the plot
labs(title = "Relación de Estado Civil y Salario", # Add a title
subtitle = "RH empresa FORM", # Add a subtitle
caption = "Relación", # Add a caption
x = "Promedio de Salario diario")bd <- bd <- read.csv("/Users/mac/Downloads/FORM - Delivery Plan.xlsx - DELIVERY PLAN(2).csv")#install.packages("dplyr")
library(dplyr)summary (bd)## CLIENTE.PLANTA PROYECTO ID.ODOO ITEM
## Length:231 Length:231 Length:231 Length:231
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
## JUNIO JULIO AGOSTO SEPTIEMBRE
## Min. : 0.00 Min. : 0.0 Min. : 0.00 Min. : 0
## 1st Qu.: 0.00 1st Qu.: 0.0 1st Qu.: 0.00 1st Qu.: 0
## Median : 0.00 Median : 0.0 Median : 0.00 Median : 0
## Mean : 29.06 Mean : 135.9 Mean : 77.45 Mean : 81
## 3rd Qu.: 0.00 3rd Qu.: 0.0 3rd Qu.: 0.00 3rd Qu.: 0
## Max. :1280.00 Max. :13120.0 Max. :3200.00 Max. :3200
## OCTUBRE NOVIEMBRE DICIEMBRE ENE.22
## Min. : 0.0 Min. : 0.00 Min. : 0.0 Min. : 0.00
## 1st Qu.: 0.0 1st Qu.: 0.00 1st Qu.: 0.0 1st Qu.: 0.00
## Median : 0.0 Median : 0.00 Median : 0.0 Median : 0.00
## Mean : 62.0 Mean : 89.69 Mean : 100.4 Mean : 82.37
## 3rd Qu.: 11.5 3rd Qu.: 4.00 3rd Qu.: 1.5 3rd Qu.: 26.50
## Max. :3200.0 Max. :6400.00 Max. :6400.0 Max. :3200.00
## FEBRERO.22 MARZO.22 ABRIL.22 MAYO.22
## Min. : 0.0 Min. : 0.0 Min. : 0.0 Min. : 0.0
## 1st Qu.: 0.0 1st Qu.: 0.0 1st Qu.: 0.0 1st Qu.: 0.0
## Median : 0.0 Median : 0.0 Median : 0.0 Median : 0.0
## Mean : 103.5 Mean : 153.9 Mean : 186.5 Mean : 187.6
## 3rd Qu.: 0.0 3rd Qu.: 20.0 3rd Qu.: 24.0 3rd Qu.: 22.0
## Max. :9600.0 Max. :9600.0 Max. :16354.0 Max. :17665.0
## JUNIO.22 JULIO.22 AGOSTO.22 SEPTIEMBRE.22
## Min. : 0.0 Min. : 0.0 Min. : 0.0 Min. : 0.0
## 1st Qu.: 0.0 1st Qu.: 0.0 1st Qu.: 0.0 1st Qu.: 0.0
## Median : 0.0 Median : 0.0 Median : 0.0 Median : 0.0
## Mean : 171.2 Mean : 316.9 Mean : 131.5 Mean : 272.3
## 3rd Qu.: 1.0 3rd Qu.: 15.5 3rd Qu.: 0.0 3rd Qu.: 0.0
## Max. :11050.0 Max. :25900.0 Max. :13200.0 Max. :29379.0
## NOVIEMBRE.22 NOVIEMBRE.22.1 DICIEMBRE.22 ENERO.23
## Min. : 0.0 Min. : 0.000 Min. : 0.000 Min. : 0.0000
## 1st Qu.: 0.0 1st Qu.: 0.000 1st Qu.: 0.000 1st Qu.: 0.0000
## Median : 0.0 Median : 0.000 Median : 0.000 Median : 0.0000
## Mean : 120.9 Mean : 2.113 Mean : 1.225 Mean : 0.5974
## 3rd Qu.: 0.0 3rd Qu.: 0.000 3rd Qu.: 0.000 3rd Qu.: 0.0000
## Max. :16421.0 Max. :324.000 Max. :276.000 Max. :138.0000
## FEBRERO.23 MARZO.23
## Min. :0 Min. :0
## 1st Qu.:0 1st Qu.:0
## Median :0 Median :0
## Mean :0 Mean :0
## 3rd Qu.:0 3rd Qu.:0
## Max. :0 Max. :0
#count(bd, JUNIO, sort= TRUE)
#count(bd, JULIO, sort= TRUE)
#count(bd, AGOSTO, sort= TRUE)
#count(bd, SEPTIEMBRE, sort= TRUE)
#count(bd, OCTUBRE, sort= TRUE)
#count(bd, NOVIEMBRE, sort= TRUE)
#count(bd, DICIEMBRE, sort= TRUE)
#count(bd, ENEROO, sort= TRUE)
#count(bd, FEBRERO22, sort= TRUE)
#count(bd, MARZO22, sort= TRUE)
#count(bd, ABRIL22, sort= TRUE)
#count(bd, MAYO22, sort= TRUE)
#count(bd, JUNIO22, sort= TRUE)
#count(bd, JULIO22, sort= TRUE)
#count(bd, AGOSTO22, sort= TRUE)
#count(bd, SEPTIEMBRE22, sort= TRUE)
#count(bd, OCTUBRE22, sort= TRUE)
#count(bd, NOVIEMBRE22, sort= TRUE)
#count(bd, DICIEMBRE22, sort= TRUE)
#count(bd, ENERO23, sort= TRUE)
#count(bd, FEBRERO23, sort= TRUE)library(dplyr)
#install.packages("psych")
library(psych)
describeData(bd, head=1, tail=1 )## n.obs = 231 of which 231 are complete cases. Number of variables = 26 of which all are numeric FALSE
## variable # n.obs type H1
## CLIENTE.PLANTA* 1 231 3 STB3
## PROYECTO* 2 231 3 CANASTILLA GRIS
## ID.ODOO* 3 231 3 15.785
## ITEM* 4 231 3 CABLE SET CAJA BACK UP CANASTILLA
## JUNIO 5 231 1 0
## JULIO 6 231 1 140
## AGOSTO 7 231 1 530
## SEPTIEMBRE 8 231 1 0
## OCTUBRE 9 231 1 200
## NOVIEMBRE 10 231 1 0
## DICIEMBRE 11 231 1 150
## ENE.22 12 231 1 230
## FEBRERO.22 13 231 1 500
## MARZO.22 14 231 1 0
## ABRIL.22 15 231 1 0
## MAYO.22 16 231 1 0
## JUNIO.22 17 231 1 200
## JULIO.22 18 231 1 900
## AGOSTO.22 19 231 1 1000
## SEPTIEMBRE.22 20 231 1 0
## NOVIEMBRE.22 21 231 1 0
## NOVIEMBRE.22.1 22 231 1 0
## DICIEMBRE.22 23 231 1 0
## ENERO.23 24 231 1 0
## FEBRERO.23 25 231 1 0
## MARZO.23 26 231 1 0
## T1
## CLIENTE.PLANTA*
## PROYECTO*
## ID.ODOO*
## ITEM* U553 KIT
## JUNIO 0
## JULIO 0
## AGOSTO 0
## SEPTIEMBRE 0
## OCTUBRE 30
## NOVIEMBRE 200
## DICIEMBRE 0
## ENE.22 0
## FEBRERO.22 0
## MARZO.22 0
## ABRIL.22 0
## MAYO.22 0
## JUNIO.22 0
## JULIO.22 0
## AGOSTO.22 0
## SEPTIEMBRE.22 0
## NOVIEMBRE.22 0
## NOVIEMBRE.22.1 0
## DICIEMBRE.22 0
## ENERO.23 0
## FEBRERO.23 0
## MARZO.23 0
#Despues de correr esta parte del codigo se puede ver que hay 26 variables y 231 registros en esta base de datosVariable<-c("`Cliente.Planta`","`Junio 2021`","`Julio 2021`","`Agosto 2021`","`Septiembre 2021`","`Octubre 2021`","`Noviembre 2021`","`Diciembre 2021`","`Enero 2022`","`Febrero 2022`","`Marzo 2022`","`Abril 2022`","`Mayo 2022`","`Junio 2022`","`Julio 2022`","`Agosto 2022`","`Septiembre 2022`","`Octubre 2022`","`Noviembre 2022`","`Diciembre 2022`","`Enero 2023`","`Febrero 2023`","`Marzo 2023`")
Type<-c("Cualitativa", "Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)","Cuantitativa(discreta)")
table<-data.frame(Variable,Type)
knitr::kable(table) | Variable | Type |
|---|---|
Cliente.Planta |
Cualitativa |
Junio 2021 |
Cuantitativa(discreta) |
Julio 2021 |
Cuantitativa(discreta) |
Agosto 2021 |
Cuantitativa(discreta) |
Septiembre 2021 |
Cuantitativa(discreta) |
Octubre 2021 |
Cuantitativa(discreta) |
Noviembre 2021 |
Cuantitativa(discreta) |
Diciembre 2021 |
Cuantitativa(discreta) |
Enero 2022 |
Cuantitativa(discreta) |
Febrero 2022 |
Cuantitativa(discreta) |
Marzo 2022 |
Cuantitativa(discreta) |
Abril 2022 |
Cuantitativa(discreta) |
Mayo 2022 |
Cuantitativa(discreta) |
Junio 2022 |
Cuantitativa(discreta) |
Julio 2022 |
Cuantitativa(discreta) |
Agosto 2022 |
Cuantitativa(discreta) |
Septiembre 2022 |
Cuantitativa(discreta) |
Octubre 2022 |
Cuantitativa(discreta) |
Noviembre 2022 |
Cuantitativa(discreta) |
Diciembre 2022 |
Cuantitativa(discreta) |
Enero 2023 |
Cuantitativa(discreta) |
Febrero 2023 |
Cuantitativa(discreta) |
Marzo 2023 |
Cuantitativa(discreta) |
bd1 <- bd
bd1<- subset(bd1, select = -c (PROYECTO, ITEM, ID.ODOO ))
# De varias tecnicas de limpieza la primera que se utilizo fue eliminar columnas y datos irrelevantes, ya que para el analisis que se desea efectuar algunos de estos datos no ayudarian.sum(is.na(bd1))## [1] 0
sum(is.na(bd))## [1] 0
# No hay NAsapply(bd1, function(x) sum(is.na(x)))## CLIENTE.PLANTA JUNIO JULIO AGOSTO SEPTIEMBRE
## 0 0 0 0 0
## OCTUBRE NOVIEMBRE DICIEMBRE ENE.22 FEBRERO.22
## 0 0 0 0 0
## MARZO.22 ABRIL.22 MAYO.22 JUNIO.22 JULIO.22
## 0 0 0 0 0
## AGOSTO.22 SEPTIEMBRE.22 NOVIEMBRE.22 NOVIEMBRE.22.1 DICIEMBRE.22
## 0 0 0 0 0
## ENERO.23 FEBRERO.23 MARZO.23
## 0 0 0
sapply(bd, function(x) sum(is.na(x)))## CLIENTE.PLANTA PROYECTO ID.ODOO ITEM JUNIO
## 0 0 0 0 0
## JULIO AGOSTO SEPTIEMBRE OCTUBRE NOVIEMBRE
## 0 0 0 0 0
## DICIEMBRE ENE.22 FEBRERO.22 MARZO.22 ABRIL.22
## 0 0 0 0 0
## MAYO.22 JUNIO.22 JULIO.22 AGOSTO.22 SEPTIEMBRE.22
## 0 0 0 0 0
## NOVIEMBRE.22 NOVIEMBRE.22.1 DICIEMBRE.22 ENERO.23 FEBRERO.23
## 0 0 0 0 0
## MARZO.23
## 0
# Aparecen varios registros como faltantes pero no es que sean faltantes si no que solo estaban cmbinadas.library(dplyr)
?colnames
bd1$NOVIEMBRE.22 <- colnames("OCTUBRE.22") base_de_datos <- read.csv("/Users/mac/Downloads/BDL1.csv")
base_de_datos$Fecha<- as.Date(base_de_datos$Fecha,format = "%d/%m/%Y")
plot(base_de_datos$Fecha, base_de_datos$Diferencia)library(tidyverse)
library(janitor)library(psych)
describe(base_de_datos)## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## vars n mean sd median trimmed mad min max range skew kurtosis
## Cliente* 1 104 2.75 1.10 2.5 2.81 1.48 1 4.00 3.00 -0.07 -1.46
## Fecha 2 104 NaN NA NA NaN NA Inf -Inf -Inf NA NA
## Diferencia 3 104 0.32 0.53 0.0 0.23 0.00 0 2.27 2.27 1.43 1.22
## X 4 0 NaN NA NA NaN NA Inf -Inf -Inf NA NA
## X.1 5 0 NaN NA NA NaN NA Inf -Inf -Inf NA NA
## X.2 6 0 NaN NA NA NaN NA Inf -Inf -Inf NA NA
## se
## Cliente* 0.11
## Fecha NA
## Diferencia 0.05
## X NA
## X.1 NA
## X.2 NA
str(base_de_datos)## 'data.frame': 104 obs. of 6 variables:
## $ Cliente : chr "PRINTEL " "MAHLE" "MAHLE" "MAHLE" ...
## $ Fecha : Date, format: "2021-07-01" "2021-07-01" ...
## $ Diferencia: num 0 0.55 1 1.1 0 0 0 0 2 0.55 ...
## $ X : logi NA NA NA NA NA NA ...
## $ X.1 : logi NA NA NA NA NA NA ...
## $ X.2 : logi NA NA NA NA NA NA ...
tabyl(base_de_datos, Cliente, Diferencia)## Cliente 0 0.1 0.4 0.55 0.8 0.95 1 1.03 1.05 1.1 1.2 1.8 2 2.27
## MAGNA 13 0 0 0 0 0 0 0 0 0 0 0 0 0
## MAHLE 10 0 1 2 1 1 15 1 1 4 1 1 0 1
## PRINTEL 10 1 0 0 0 0 0 0 0 0 1 0 1 0
## VARROC 39 0 0 0 0 0 0 0 0 0 0 0 0 0
variable<-c("Cliente","Fecha", "Diferencia")
type <- c("Cualitativo (nominal)","Cuantitativo (disccreta)", "Cuantitativo (continuo)")
table<-data.frame(variable,type)
knitr::kable(table)| variable | type |
|---|---|
| Cliente | Cualitativo (nominal) |
| Fecha | Cuantitativo (disccreta) |
| Diferencia | Cuantitativo (continuo) |
#Eliminar columnas
DeliveryBD <-base_de_datos
DeliveryBD <- subset ( DeliveryBD, select = -c (X, X.1, X.2))
bd2 <-base_de_datos
bd2 <- subset(bd2, select = -c (Fecha, X, X.1, X.2))
media_perfo <- mean(bd2$Diferencia)
mediana_perfo <- median(bd2$Diferencia)
mode <- function (x) {
ux <- unique(x)
ux [which.max(tabulate(match(x,ux)))]
}
mode_perfo <- mode(bd2$Diferencia)
mode_perfo## [1] 0
hist(bd2$Diferencia)#Eliminar valores negativos
bd1<-DeliveryBD
bd1[bd1 <0] <-0
summary(bd1)## Cliente Fecha Diferencia
## Length:104 Min. :2021-07-01 Min. :0.0000
## Class :character 1st Qu.:2021-10-01 1st Qu.:0.0000
## Mode :character Median :2022-01-01 Median :0.0000
## Mean :2021-12-31 Mean :0.3202
## 3rd Qu.:2022-04-01 3rd Qu.:0.9625
## Max. :2022-07-01 Max. :2.2700
count(bd2, Cliente, sort = TRUE)## Cliente n
## 1 MAHLE 39
## 2 VARROC 39
## 3 MAGNA 13
## 4 PRINTEL 13
ggplot(bd2, aes(x=media_perfo, y=Cliente)) +
geom_bar(stat="identity", fill="orange") + scale_fill_grey() + # Add bars to the plot
labs(title = "Diferencia entre clientes", # Add a title
subtitle = "Dperformance empresa FORM", # Add a subtitle
caption = "Relación", # Add a caption
x = "Diferencia")bd <-read.csv("/Users/mac/Downloads/us_motor_production_and_domestic_sales.csv")summary(bd)## Year Total_Production Production_Passenger_Cars
## Min. :1965 Min. : 5710 Min. :1924
## 1st Qu.:1994 1st Qu.: 9510 1st Qu.:3904
## Median :2002 Median :11220 Median :4631
## Mean :2001 Mean :10698 Mean :4867
## 3rd Qu.:2011 3rd Qu.:11997 3rd Qu.:5995
## Max. :2020 Max. :13025 Max. :9329
## Production_Commercial_Vehicles Domestic_Sales Sales_Passenger_Cars
## Min. :1638 Min. : 7868 Min. :2560
## 1st Qu.:4661 1st Qu.:10651 1st Qu.:5139
## Median :6381 Median :13222 Median :5713
## Mean :5831 Mean :12265 Mean :5810
## 3rd Qu.:7418 3rd Qu.:13757 3rd Qu.:6876
## Max. :8512 Max. :14923 Max. :8763
## Sales_Commercial_Vehicles
## Min. : 1539
## 1st Qu.: 5042
## Median : 6867
## Mean : 6455
## 3rd Qu.: 8162
## Max. :10133
str(bd)## 'data.frame': 36 obs. of 7 variables:
## $ Year : int 1965 1970 1975 1980 1985 1990 1991 1992 1993 1994 ...
## $ Total_Production : num 11114 8263 8965 8011 11638 ...
## $ Production_Passenger_Cars : num 9329 6546 6706 6372 8186 ...
## $ Production_Commercial_Vehicles: num 1785 1717 2260 1638 3452 ...
## $ Domestic_Sales : num 10302 8849 9298 8594 12110 ...
## $ Sales_Passenger_Cars : num 8763 7112 6945 6580 8205 ...
## $ Sales_Commercial_Vehicles : num 1539 1737 2353 2015 3905 ...
Variable<-c("`Year´","`Total_Production`","`Production_Passenger_Cars`","`Production_Commercial_Vehicles`","`Domestic_Sales`","`Sales_Passenger_Cars`","`Sales_Commercial_Vehicles`")
Type<-c("quantiative (discrete)", "quantiative (continous)", "quantitative (continous)", "quantitative (continous)", "quantitative (continous)", "quantitative (continous)", "quantitative (continous)")
table<-data.frame(Variable,Type)
knitr::kable(table)| Variable | Type |
|---|---|
Year´ |quantiative (discrete) | |Total_Production|quantiative (continous) | |Production_Passenger_Cars|quantitative (continous) | |Production_Commercial_Vehicles|quantitative (continous) | |Domestic_Sales|quantitative (continous) | |Sales_Passenger_Cars|quantitative (continous) | |Sales_Commercial_Vehicles` |
quantitative (continous) |
bd[duplicated(bd), ]## [1] Year Total_Production
## [3] Production_Passenger_Cars Production_Commercial_Vehicles
## [5] Domestic_Sales Sales_Passenger_Cars
## [7] Sales_Commercial_Vehicles
## <0 rows> (or 0-length row.names)
sum(duplicated(bd))## [1] 0
bd1<-bd
bd1[bd1 <0] <-0
summary(bd1)## Year Total_Production Production_Passenger_Cars
## Min. :1965 Min. : 5710 Min. :1924
## 1st Qu.:1994 1st Qu.: 9510 1st Qu.:3904
## Median :2002 Median :11220 Median :4631
## Mean :2001 Mean :10698 Mean :4867
## 3rd Qu.:2011 3rd Qu.:11997 3rd Qu.:5995
## Max. :2020 Max. :13025 Max. :9329
## Production_Commercial_Vehicles Domestic_Sales Sales_Passenger_Cars
## Min. :1638 Min. : 7868 Min. :2560
## 1st Qu.:4661 1st Qu.:10651 1st Qu.:5139
## Median :6381 Median :13222 Median :5713
## Mean :5831 Mean :12265 Mean :5810
## 3rd Qu.:7418 3rd Qu.:13757 3rd Qu.:6876
## Max. :8512 Max. :14923 Max. :8763
## Sales_Commercial_Vehicles
## Min. : 1539
## 1st Qu.: 5042
## Median : 6867
## Mean : 6455
## 3rd Qu.: 8162
## Max. :10133
production <-bd
production <- subset (production, select = -c (Total_Production, Domestic_Sales, Sales_Passenger_Cars, Sales_Commercial_Vehicles))production3 <- production
production3 <- production3[production3$Year> 2010, ]ggplot(production3,aes(x=Year,y=Production_Passenger_Cars,fill=Production_Commercial_Vehicles))+
geom_bar(stat="identity")+
theme_minimal()+
labs(title="Relación Produccion Passengers y Commercial")