Los datos
# Cargar datos de salarios
# salarios <- read.csv("Va la ruta en donde estan los datos")
salarios <- read_csv("C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv")
## Parsed with column specification:
## cols(
## Id = col_double(),
## EmployeeName = col_character(),
## JobTitle = col_character(),
## BasePay = col_double(),
## OvertimePay = col_double(),
## OtherPay = col_double(),
## Benefits = col_logical(),
## TotalPay = col_double(),
## TotalPayBenefits = col_double(),
## Year = col_double(),
## Notes = col_logical(),
## Agency = col_character(),
## Status = col_logical()
## )
## Warning: 150614 parsing failures.
## row col expected actual file
## 36160 Benefits 1/0/T/F/TRUE/FALSE 44430.12 'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'
## 36161 Benefits 1/0/T/F/TRUE/FALSE 69810.19 'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'
## 36162 Benefits 1/0/T/F/TRUE/FALSE 53102.29 'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'
## 36163 Benefits 1/0/T/F/TRUE/FALSE 72047.88 'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'
## 36164 Benefits 1/0/T/F/TRUE/FALSE 44438.25 'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'
## ..... ........ .................. ........ ..................................................................
## See problems(...) for more details.
head (salarios)
## # A tibble: 6 x 13
## Id EmployeeName JobTitle BasePay OvertimePay OtherPay Benefits
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <lgl>
## 1 1 NATHANIEL F~ GENERAL~ 167411. 0 400184. NA
## 2 2 GARY JIMENEZ CAPTAIN~ 155966. 245132. 137811. NA
## 3 3 ALBERT PARD~ CAPTAIN~ 212739. 106088. 16453. NA
## 4 4 CHRISTOPHER~ WIRE RO~ 77916 56121. 198307. NA
## 5 5 PATRICK GAR~ DEPUTY ~ 134402. 9737 182235. NA
## 6 6 DAVID SULLI~ ASSISTA~ 118602 8601 189083. NA
## # ... with 6 more variables: TotalPay <dbl>, TotalPayBenefits <dbl>,
## # Year <dbl>, Notes <lgl>, Agency <chr>, Status <lgl>
str(salarios)
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 148654 obs. of 13 variables:
## $ Id : num 1 2 3 4 5 6 7 8 9 10 ...
## $ EmployeeName : chr "NATHANIEL FORD" "GARY JIMENEZ" "ALBERT PARDINI" "CHRISTOPHER CHONG" ...
## $ JobTitle : chr "GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY" "CAPTAIN III (POLICE DEPARTMENT)" "CAPTAIN III (POLICE DEPARTMENT)" "WIRE ROPE CABLE MAINTENANCE MECHANIC" ...
## $ BasePay : num 167411 155966 212739 77916 134402 ...
## $ OvertimePay : num 0 245132 106088 56121 9737 ...
## $ OtherPay : num 400184 137811 16453 198307 182235 ...
## $ Benefits : logi NA NA NA NA NA NA ...
## $ TotalPay : num 567595 538909 335280 332344 326373 ...
## $ TotalPayBenefits: num 567595 538909 335280 332344 326373 ...
## $ Year : num 2011 2011 2011 2011 2011 ...
## $ Notes : logi NA NA NA NA NA NA ...
## $ Agency : chr "San Francisco" "San Francisco" "San Francisco" "San Francisco" ...
## $ Status : logi NA NA NA NA NA NA ...
## - attr(*, "problems")=Classes 'tbl_df', 'tbl' and 'data.frame': 150614 obs. of 5 variables:
## ..$ row : int 36160 36161 36162 36163 36164 36165 36166 36167 36168 36169 ...
## ..$ col : chr "Benefits" "Benefits" "Benefits" "Benefits" ...
## ..$ expected: chr "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" ...
## ..$ actual : chr "44430.12" "69810.19" "53102.29" "72047.88" ...
## ..$ file : chr "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" ...
## - attr(*, "spec")=
## .. cols(
## .. Id = col_double(),
## .. EmployeeName = col_character(),
## .. JobTitle = col_character(),
## .. BasePay = col_double(),
## .. OvertimePay = col_double(),
## .. OtherPay = col_double(),
## .. Benefits = col_logical(),
## .. TotalPay = col_double(),
## .. TotalPayBenefits = col_double(),
## .. Year = col_double(),
## .. Notes = col_logical(),
## .. Agency = col_character(),
## .. Status = col_logical()
## .. )
summary (salarios)
## Id EmployeeName JobTitle BasePay
## Min. : 1 Length:148654 Length:148654 Min. : -166
## 1st Qu.: 37164 Class :character Class :character 1st Qu.: 33588
## Median : 74328 Mode :character Mode :character Median : 65007
## Mean : 74328 Mean : 66325
## 3rd Qu.:111491 3rd Qu.: 94691
## Max. :148654 Max. :319275
## NA's :609
## OvertimePay OtherPay Benefits TotalPay
## Min. : -0.01 Min. : -7058.6 Mode:logical Min. : -618.1
## 1st Qu.: 0.00 1st Qu.: 0.0 NA's:148654 1st Qu.: 36169.0
## Median : 0.00 Median : 811.3 Median : 71426.6
## Mean : 5066.06 Mean : 3648.8 Mean : 74768.3
## 3rd Qu.: 4658.18 3rd Qu.: 4236.1 3rd Qu.:105839.1
## Max. :245131.88 Max. :400184.2 Max. :567595.4
## NA's :4 NA's :4
## TotalPayBenefits Year Notes Agency
## Min. : -618.1 Min. :2011 Mode:logical Length:148654
## 1st Qu.: 44065.7 1st Qu.:2012 NA's:148654 Class :character
## Median : 92404.1 Median :2013 Mode :character
## Mean : 93692.6 Mean :2013
## 3rd Qu.:132876.5 3rd Qu.:2014
## Max. :567595.4 Max. :2014
##
## Status
## Mode:logical
## NA's:148654
##
##
##
##
##
Filtrar datos del empleado Kevin Lee del año 2014
filter(salarios, EmployeeName == "Kevin Lee")
## # A tibble: 13 x 13
## Id EmployeeName JobTitle BasePay OvertimePay OtherPay Benefits
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <lgl>
## 1 39716 Kevin Lee Police ~ 115867. 23523. 9314. NA
## 2 40571 Kevin Lee Police ~ 117171. 19607. 4245. NA
## 3 42511 Kevin Lee Electri~ 79221. 40247. 3353. NA
## 4 49271 Kevin Lee Deputy ~ 84512. 0 1470. NA
## 5 49440 Kevin Lee Deputy ~ 84512. 0 975. NA
## 6 50124 Kevin Lee Personn~ 83382 0 0 NA
## 7 52234 Kevin Lee Senior ~ 66774. 9599. 1093. NA
## 8 53932 Kevin Lee Transit~ 57397. 9990. 1800. NA
## 9 55120 Kevin Lee IS Admi~ 68940. 0 0 NA
## 10 112386 Kevin Lee Sergean~ 137982. 18537. 16040. NA
## 11 123142 Kevin Lee IT Oper~ 91606. 0 1013 NA
## 12 124166 Kevin Lee Personn~ 88353. 0 0 NA
## 13 124659 Kevin Lee Transit~ 67230. 10961. 4051. NA
## # ... with 6 more variables: TotalPay <dbl>, TotalPayBenefits <dbl>,
## # Year <dbl>, Notes <lgl>, Agency <chr>, Status <lgl>
filter(salarios, EmployeeName == "Kevin Lee" & Year == 2014)
## # A tibble: 4 x 13
## Id EmployeeName JobTitle BasePay OvertimePay OtherPay Benefits
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <lgl>
## 1 112386 Kevin Lee Sergean~ 137982. 18537. 16040. NA
## 2 123142 Kevin Lee IT Oper~ 91606. 0 1013 NA
## 3 124166 Kevin Lee Personn~ 88353. 0 0 NA
## 4 124659 Kevin Lee Transit~ 67230. 10961. 4051. NA
## # ... with 6 more variables: TotalPay <dbl>, TotalPayBenefits <dbl>,
## # Year <dbl>, Notes <lgl>, Agency <chr>, Status <lgl>
Cuántos empleados están entre un salario total de 150000 y 170000 en el 2012
cuantos <- filter(salarios, TotalPayBenefits >= 150000 & TotalPayBenefits <= 170000 & Year == 2012)
str(cuantos) # Estructura de cuantos
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 2913 obs. of 13 variables:
## $ Id : num 41218 41219 41220 41221 41222 ...
## $ EmployeeName : chr "Cheryl De Lemos" "Daniel Godfrey" "Robert Harvey" "Lawrence McDonnell" ...
## $ JobTitle : chr "Registered Nurse" "Utility Plumber Supervisor 1" "Automotive Mechanic Sprv 1" "Firefighter" ...
## $ BasePay : num 112611 102662 97609 110847 88374 ...
## $ OvertimePay : num 5648 19465 22952 3927 33428 ...
## $ OtherPay : num 6037 6254 8148 18492 10512 ...
## $ Benefits : logi NA NA NA NA NA NA ...
## $ TotalPay : num 124296 128382 128709 133266 132314 ...
## $ TotalPayBenefits: num 169995 169990 169982 169980 169973 ...
## $ Year : num 2012 2012 2012 2012 2012 ...
## $ Notes : logi NA NA NA NA NA NA ...
## $ Agency : chr "San Francisco" "San Francisco" "San Francisco" "San Francisco" ...
## $ Status : logi NA NA NA NA NA NA ...
## - attr(*, "problems")=Classes 'tbl_df', 'tbl' and 'data.frame': 150614 obs. of 5 variables:
## ..$ row : int 36160 36161 36162 36163 36164 36165 36166 36167 36168 36169 ...
## ..$ col : chr "Benefits" "Benefits" "Benefits" "Benefits" ...
## ..$ expected: chr "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" ...
## ..$ actual : chr "44430.12" "69810.19" "53102.29" "72047.88" ...
## ..$ file : chr "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" ...
## - attr(*, "spec")=
## .. cols(
## .. Id = col_double(),
## .. EmployeeName = col_character(),
## .. JobTitle = col_character(),
## .. BasePay = col_double(),
## .. OvertimePay = col_double(),
## .. OtherPay = col_double(),
## .. Benefits = col_logical(),
## .. TotalPay = col_double(),
## .. TotalPayBenefits = col_double(),
## .. Year = col_double(),
## .. Notes = col_logical(),
## .. Agency = col_character(),
## .. Status = col_logical()
## .. )
nrow(cuantos) # Cuantos registros
## [1] 2913
Cuantos regsitros hay por encima del cuartil 75
cuartil75 <- quantile(salarios$TotalPayBenefits, 0.75)
cuantos <- filter(salarios, TotalPayBenefits >= cuartil75)
str(cuantos) # Estructura de cuantos
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 37164 obs. of 13 variables:
## $ Id : num 1 2 3 4 5 6 7 8 9 10 ...
## $ EmployeeName : chr "NATHANIEL FORD" "GARY JIMENEZ" "ALBERT PARDINI" "CHRISTOPHER CHONG" ...
## $ JobTitle : chr "GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY" "CAPTAIN III (POLICE DEPARTMENT)" "CAPTAIN III (POLICE DEPARTMENT)" "WIRE ROPE CABLE MAINTENANCE MECHANIC" ...
## $ BasePay : num 167411 155966 212739 77916 134402 ...
## $ OvertimePay : num 0 245132 106088 56121 9737 ...
## $ OtherPay : num 400184 137811 16453 198307 182235 ...
## $ Benefits : logi NA NA NA NA NA NA ...
## $ TotalPay : num 567595 538909 335280 332344 326373 ...
## $ TotalPayBenefits: num 567595 538909 335280 332344 326373 ...
## $ Year : num 2011 2011 2011 2011 2011 ...
## $ Notes : logi NA NA NA NA NA NA ...
## $ Agency : chr "San Francisco" "San Francisco" "San Francisco" "San Francisco" ...
## $ Status : logi NA NA NA NA NA NA ...
## - attr(*, "problems")=Classes 'tbl_df', 'tbl' and 'data.frame': 150614 obs. of 5 variables:
## ..$ row : int 36160 36161 36162 36163 36164 36165 36166 36167 36168 36169 ...
## ..$ col : chr "Benefits" "Benefits" "Benefits" "Benefits" ...
## ..$ expected: chr "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" ...
## ..$ actual : chr "44430.12" "69810.19" "53102.29" "72047.88" ...
## ..$ file : chr "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" "'C:/Users/tthan/Documents/CIENCIA DE LOS DATOS/Datos/Salaries.csv'" ...
## - attr(*, "spec")=
## .. cols(
## .. Id = col_double(),
## .. EmployeeName = col_character(),
## .. JobTitle = col_character(),
## .. BasePay = col_double(),
## .. OvertimePay = col_double(),
## .. OtherPay = col_double(),
## .. Benefits = col_logical(),
## .. TotalPay = col_double(),
## .. TotalPayBenefits = col_double(),
## .. Year = col_double(),
## .. Notes = col_logical(),
## .. Agency = col_character(),
## .. Status = col_logical()
## .. )
nrow(cuantos) # Cuantos registros
## [1] 37164
Proyectar atributos de un conjunto de datos por medio de select
Primero un select y luego un filter o viceversa
registros <- select(salarios, Id, EmployeeName, TotalPayBenefits, Year)
# registros
cuales <- filter(registros, TotalPayBenefits >= 150000 & TotalPayBenefits <= 170000 & Year == 2012)
cuales
## # A tibble: 2,913 x 4
## Id EmployeeName TotalPayBenefits Year
## <dbl> <chr> <dbl> <dbl>
## 1 41218 Cheryl De Lemos 169995. 2012
## 2 41219 Daniel Godfrey 169990. 2012
## 3 41220 Robert Harvey 169982. 2012
## 4 41221 Lawrence McDonnell 169980. 2012
## 5 41222 Sergio Chavez 169973. 2012
## 6 41223 Michael Grande 169970. 2012
## 7 41224 Jeffrey Chow 169963. 2012
## 8 41225 Winilyn Hidalgo 169960. 2012
## 9 41226 Rodney Lee 169960. 2012
## 10 41227 Lucille Palma 169941. 2012
## # ... with 2,903 more rows
Ordenar los datos con arrange
datosOrdenados <- arrange(cuales, EmployeeName) # Por defaut es de menor a mayor
head(datosOrdenados) # Los primeros seis
## # A tibble: 6 x 4
## Id EmployeeName TotalPayBenefits Year
## <dbl> <chr> <dbl> <dbl>
## 1 42773 Aaron Ballonado 159733. 2012
## 2 41480 Aaron Cowhig 168330. 2012
## 3 42067 Aaron Fischer 164281. 2012
## 4 41965 Aaron Smith 164961. 2012
## 5 42777 Aaron Yoo 159712. 2012
## 6 42739 Abraham Abarca 159989. 2012
tail(datosOrdenados) # Los últimos seis
## # A tibble: 6 x 4
## Id EmployeeName TotalPayBenefits Year
## <dbl> <chr> <dbl> <dbl>
## 1 41326 Yvonne Fuentes-Pattishall 169172. 2012
## 2 43221 Zahid Khan 156873. 2012
## 3 42623 Zara Grace Janer 160767. 2012
## 4 44083 Zhong Qiu 150289. 2012
## 5 41647 Zoila Maguina 167055. 2012
## 6 42196 Zula Jones 163423. 2012
Agregar columnas nuevas al conjunto de datos
Pueden ser al original o al que ya se tiene fitrado
Agregar un valor de 0 o 1 para genero
# Poner una semilla igual todos para generar la misma muestra
set.seed(1000) # Un valor de semilla
# Vamos a generar genros 0 y 1
generos <- rep(0:1, 5000) # Es un repetición de 5000 valores entre 0 y 1. Solo necesitamos 2913, hacemos una muestra
generos <- sample(generos, 2913) # sample genera una muestra de 2913 registros
generos
## [1] 1 1 0 0 1 0 1 1 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 0 0 0
## [35] 1 1 1 0 1 0 0 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0
## [69] 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 1 0 0 0 1 1
## [103] 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0 0 1
## [137] 1 1 0 0 0 1 1 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1 1 1 0
## [171] 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1
## [205] 1 1 1 1 0 0 1 0 1 0 0 1 0 1 0 1 1 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1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1 0 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1 0 1 1 1
## [2619] 1 1 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 0 1 0
## [2653] 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 1 0 1 1 0 1 0 1 0 1 1 0
## [2687] 0 1 0 0 1 1 0 0 1 0 1 0 1 1 1 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 1 1 0 1
## [2721] 1 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 0 0 0 1 0 0 1
## [2755] 0 1 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0
## [2789] 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 0 1 1 0 0 1 1
## [2823] 0 0 0 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0
## [2857] 0 1 1 0 0 0 0 1 0 1 1 1 0 0 1 0 1 1 0 1 0 1 0 1 1 1 1 1 0 0 1 0 1 0
## [2891] 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 0
cuales <- mutate(cuales, genero = generos) # Agrega columna genero a cuales
head(cuales, 10) # Los primeros 10
## # A tibble: 10 x 5
## Id EmployeeName TotalPayBenefits Year genero
## <dbl> <chr> <dbl> <dbl> <int>
## 1 41218 Cheryl De Lemos 169995. 2012 1
## 2 41219 Daniel Godfrey 169990. 2012 1
## 3 41220 Robert Harvey 169982. 2012 0
## 4 41221 Lawrence McDonnell 169980. 2012 0
## 5 41222 Sergio Chavez 169973. 2012 1
## 6 41223 Michael Grande 169970. 2012 0
## 7 41224 Jeffrey Chow 169963. 2012 1
## 8 41225 Winilyn Hidalgo 169960. 2012 1
## 9 41226 Rodney Lee 169960. 2012 1
## 10 41227 Lucille Palma 169941. 2012 0
cuales # Van todos
## # A tibble: 2,913 x 5
## Id EmployeeName TotalPayBenefits Year genero
## <dbl> <chr> <dbl> <dbl> <int>
## 1 41218 Cheryl De Lemos 169995. 2012 1
## 2 41219 Daniel Godfrey 169990. 2012 1
## 3 41220 Robert Harvey 169982. 2012 0
## 4 41221 Lawrence McDonnell 169980. 2012 0
## 5 41222 Sergio Chavez 169973. 2012 1
## 6 41223 Michael Grande 169970. 2012 0
## 7 41224 Jeffrey Chow 169963. 2012 1
## 8 41225 Winilyn Hidalgo 169960. 2012 1
## 9 41226 Rodney Lee 169960. 2012 1
## 10 41227 Lucille Palma 169941. 2012 0
## # ... with 2,903 more rows
Agregar columnas nuevas al conjunto de datos
Pueden ser al original o al que ya se tiene fitrado
Agregar un valor de 1, 2, 3, 4 o 5 para edocivil
# Poner una semilla igual todos para generar la misma muestra
set.seed(1000) # Un valor de semilla
# Vamos a generar genros 0 y 1
edociviles <- rep(1:5, 5000) # Es un repetición de 5000 valores entre 0 y 1. Solo necesitamos 2913, hacemos una muestra
edociviles <- sample(edociviles, 2913) # sample genera una muestra de 2913 registros
generos
## [1] 1 1 0 0 1 0 1 1 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 0 0 0
## [35] 1 1 1 0 1 0 0 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0
## [69] 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 1 0 0 0 1 1
## [103] 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0 0 1
## [137] 1 1 0 0 0 1 1 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1 1 1 0
## [171] 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 1 0 0 1 1 0 1 0 0 0 0 0 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0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0 0
## [2585] 1 1 1 1 0 1 1 1 1 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1 0 1 1 1
## [2619] 1 1 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 0 1 0
## [2653] 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 1 0 1 1 0 1 0 1 0 1 1 0
## [2687] 0 1 0 0 1 1 0 0 1 0 1 0 1 1 1 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 1 1 0 1
## [2721] 1 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 0 0 0 1 0 0 1
## [2755] 0 1 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0
## [2789] 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 0 1 1 0 0 1 1
## [2823] 0 0 0 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0
## [2857] 0 1 1 0 0 0 0 1 0 1 1 1 0 0 1 0 1 1 0 1 0 1 0 1 1 1 1 1 0 0 1 0 1 0
## [2891] 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 0
#cuales <- mutate(cuales, edocivil = edociviles) # Agrega columna edocivil a cuales
#head(cuales, 10) # Los primeros 10
#cuales # Van todos
Cuantos hay de genero 0 y de genero 1
# Genera una tabla cruzada o lo que es o mismo al frecuencia de clases de algua variable en este caso genero
table(cuales$genero)
##
## 0 1
## 1468 1445
Cuantos hay de genero 0 y de genero 1
# Genera una tabla cruzada o lo que es o mismo al frecuencia de clases de algua variable en este caso genero
table(cuales$edocivil)
## Warning: Unknown or uninitialised column: 'edocivil'.
## < table of extent 0 >
Vamos a ver un histograma de genero
barplot(table(cuales$genero))
