OBJETIVO. Analizar datos de salarios

Utilizr la libreria dplyr para analizar datos de salarios

Las librerias

library(readr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Los datos

# Cargar datos de salarios
# salarios <- read.csv("Va la ruta en donde estan los datos")
salarios <- read.csv("C:/Users/Guadalupe Medina/Documents/Ciencia de los Datos/Datos/Salaries.csv")

# salarios   # Ya no los queremos ver

str(salarios) # ve los atributos o variables
## 'data.frame':    148654 obs. of  13 variables:
##  $ Id              : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ EmployeeName    : Factor w/ 110810 levels "A Bernard  Fatooh",..: 77636 34712 1560 17232 81101 23164 3271 22709 73975 47938 ...
##  $ JobTitle        : Factor w/ 2159 levels "Account Clerk",..: 836 298 298 2149 594 135 246 609 246 370 ...
##  $ BasePay         : num  167411 155966 212739 77916 134402 ...
##  $ OvertimePay     : num  0 245132 106088 56121 9737 ...
##  $ OtherPay        : num  400184 137811 16453 198307 182235 ...
##  $ Benefits        : num  NA NA NA NA NA NA NA NA NA NA ...
##  $ TotalPay        : num  567595 538909 335280 332344 326373 ...
##  $ TotalPayBenefits: num  567595 538909 335280 332344 326373 ...
##  $ Year            : int  2011 2011 2011 2011 2011 2011 2011 2011 2011 2011 ...
##  $ Notes           : logi  NA NA NA NA NA NA ...
##  $ Agency          : Factor w/ 1 level "San Francisco": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Status          : Factor w/ 3 levels "","FT","PT": 1 1 1 1 1 1 1 1 1 1 ...
summary(salarios)
##        Id               EmployeeName   
##  Min.   :     1   Kevin Lee   :    13  
##  1st Qu.: 37164   Richard Lee :    11  
##  Median : 74328   Steven Lee  :    11  
##  Mean   : 74328   William Wong:    11  
##  3rd Qu.:111491   John Chan   :     9  
##  Max.   :148654   KEVIN LEE   :     9  
##                   (Other)     :148590  
##                          JobTitle         BasePay      
##  Transit Operator            :  7036   Min.   :  -166  
##  Special Nurse               :  4389   1st Qu.: 33588  
##  Registered Nurse            :  3736   Median : 65007  
##  Public Svc Aide-Public Works:  2518   Mean   : 66325  
##  Police Officer 3            :  2421   3rd Qu.: 94691  
##  Custodian                   :  2418   Max.   :319275  
##  (Other)                     :126136   NA's   :609     
##   OvertimePay           OtherPay           Benefits       
##  Min.   :    -0.01   Min.   : -7058.6   Min.   :  -33.89  
##  1st Qu.:     0.00   1st Qu.:     0.0   1st Qu.:11535.40  
##  Median :     0.00   Median :   811.3   Median :28628.62  
##  Mean   :  5066.06   Mean   :  3648.8   Mean   :25007.89  
##  3rd Qu.:  4658.18   3rd Qu.:  4236.1   3rd Qu.:35566.86  
##  Max.   :245131.88   Max.   :400184.2   Max.   :96570.66  
##  NA's   :4           NA's   :4          NA's   :36163     
##     TotalPay        TotalPayBenefits        Year       Notes        
##  Min.   :  -618.1   Min.   :  -618.1   Min.   :2011   Mode:logical  
##  1st Qu.: 36169.0   1st Qu.: 44065.7   1st Qu.:2012   NA's:148654   
##  Median : 71426.6   Median : 92404.1   Median :2013                 
##  Mean   : 74768.3   Mean   : 93692.6   Mean   :2013                 
##  3rd Qu.:105839.1   3rd Qu.:132876.5   3rd Qu.:2014                 
##  Max.   :567595.4   Max.   :567595.4   Max.   :2014                 
##                                                                     
##            Agency       Status     
##  San Francisco:148654     :110535  
##                         FT: 22334  
##                         PT: 15785  
##                                    
##                                    
##                                    
## 
head(salarios)  # Los primeros seis registros
##   Id      EmployeeName                                       JobTitle
## 1  1    NATHANIEL FORD GENERAL MANAGER-METROPOLITAN TRANSIT AUTHORITY
## 2  2      GARY JIMENEZ                CAPTAIN III (POLICE DEPARTMENT)
## 3  3    ALBERT PARDINI                CAPTAIN III (POLICE DEPARTMENT)
## 4  4 CHRISTOPHER CHONG           WIRE ROPE CABLE MAINTENANCE MECHANIC
## 5  5   PATRICK GARDNER   DEPUTY CHIEF OF DEPARTMENT,(FIRE DEPARTMENT)
## 6  6    DAVID SULLIVAN                      ASSISTANT DEPUTY CHIEF II
##    BasePay OvertimePay OtherPay Benefits TotalPay TotalPayBenefits Year
## 1 167411.2        0.00 400184.2       NA 567595.4         567595.4 2011
## 2 155966.0   245131.88 137811.4       NA 538909.3         538909.3 2011
## 3 212739.1   106088.18  16452.6       NA 335279.9         335279.9 2011
## 4  77916.0    56120.71 198306.9       NA 332343.6         332343.6 2011
## 5 134401.6     9737.00 182234.6       NA 326373.2         326373.2 2011
## 6 118602.0     8601.00 189082.7       NA 316285.7         316285.7 2011
##   Notes        Agency Status
## 1    NA San Francisco       
## 2    NA San Francisco       
## 3    NA San Francisco       
## 4    NA San Francisco       
## 5    NA San Francisco       
## 6    NA San Francisco

Fitrar datos de empleado Kevin Lee" & Year == 201

filter(salarios, EmployeeName == "Kevin Lee")
##        Id EmployeeName                       JobTitle   BasePay
## 1   39716    Kevin Lee               Police Officer 3 115866.90
## 2   40571    Kevin Lee               Police Officer 3 117171.41
## 3   42511    Kevin Lee Electrical Transit System Mech  79220.54
## 4   49271    Kevin Lee         Deputy Court Clerk III  84512.32
## 5   49440    Kevin Lee         Deputy Court Clerk III  84512.34
## 6   50124    Kevin Lee              Personnel Analyst  83382.00
## 7   52234    Kevin Lee Senior Parking Control Officer  66774.03
## 8   53932    Kevin Lee               Transit Operator  57397.32
## 9   55120    Kevin Lee             IS Administrator 2  68940.44
## 10 112386    Kevin Lee                     Sergeant 3 137982.14
## 11 123142    Kevin Lee IT Operations Support Admin IV  91606.03
## 12 124166    Kevin Lee              Personnel Analyst  88353.01
## 13 124659    Kevin Lee               Transit Operator  67230.30
##    OvertimePay OtherPay Benefits  TotalPay TotalPayBenefits Year Notes
## 1     23523.30  9313.54 34906.20 148703.74        183609.94 2012    NA
## 2     19606.88  4244.90 34610.10 141023.19        175633.29 2012    NA
## 3     40247.39  3353.49 38781.04 122821.42        161602.46 2012    NA
## 4         0.00  1469.99 36080.30  85982.31        122062.61 2012    NA
## 5         0.00   975.44 35902.02  85487.78        121389.80 2012    NA
## 6         0.00     0.00 35210.59  83382.00        118592.59 2012    NA
## 7      9599.08  1092.62 31902.38  77465.73        109368.11 2012    NA
## 8      9989.83  1800.48 34577.54  69187.63        103765.17 2012    NA
## 9         0.00     0.00 30650.48  68940.44         99590.92 2012    NA
## 10    18537.19 16039.62 43039.12 172558.95        215598.07 2014    NA
## 11        0.00  1013.00 34109.61  92619.03        126728.64 2014    NA
## 12        0.00     0.00 33172.33  88353.01        121525.34 2014    NA
## 13    10961.25  4050.85 36777.83  82242.40        119020.23 2014    NA
##           Agency Status
## 1  San Francisco       
## 2  San Francisco       
## 3  San Francisco       
## 4  San Francisco       
## 5  San Francisco       
## 6  San Francisco       
## 7  San Francisco       
## 8  San Francisco       
## 9  San Francisco       
## 10 San Francisco     FT
## 11 San Francisco     FT
## 12 San Francisco     FT
## 13 San Francisco     FT
filter(salarios, EmployeeName == "Kevin Lee" & Year == 2014)
##       Id EmployeeName                       JobTitle   BasePay OvertimePay
## 1 112386    Kevin Lee                     Sergeant 3 137982.14    18537.19
## 2 123142    Kevin Lee IT Operations Support Admin IV  91606.03        0.00
## 3 124166    Kevin Lee              Personnel Analyst  88353.01        0.00
## 4 124659    Kevin Lee               Transit Operator  67230.30    10961.25
##   OtherPay Benefits  TotalPay TotalPayBenefits Year Notes        Agency
## 1 16039.62 43039.12 172558.95         215598.1 2014    NA San Francisco
## 2  1013.00 34109.61  92619.03         126728.6 2014    NA San Francisco
## 3     0.00 33172.33  88353.01         121525.3 2014    NA San Francisco
## 4  4050.85 36777.83  82242.40         119020.2 2014    NA San Francisco
##   Status
## 1     FT
## 2     FT
## 3     FT
## 4     FT

Analisis elemental

La media

Desviacion

Máximo

Mínimo

maximo <- max(salarios$TotalPayBenefits)
minimo <- min(salarios$TotalPayBenefits)
media <- mean(salarios$TotalPayBenefits)
desvstd <- sd(salarios$TotalPayBenefits)

Mostrar los valores estadisticos

paste("Valor maximo de Ingreso Total",maximo)
## [1] "Valor maximo de Ingreso Total 567595.43"
paste("Valor minimo de Ingreso Total",minimo)
## [1] "Valor minimo de Ingreso Total -618.13"
paste("La media de Ingreso Total",media)
## [1] "La media de Ingreso Total 93692.5548105668"
paste("La desviacion estandard de Ingreso Total",desvstd)
## [1] "La desviacion estandard de Ingreso Total 62793.5334832377"

Analisis de datos

En esta practica se saca la media, máximo, minimo y desviación estandar

de una base de datos de sueldos, el valór maximo de Ingreso Total es de 567595.43

y el valor mínimo es de -618.13 la media es de 93692.5548105668 y por ultimo el Valor

de la desviación Standard es de 62793.5334832377