ISME-RProg-Ex2-DataCleaning-009-RohanKhollamkar

Load Libraries

library(tidyr)
## Warning: package 'tidyr' was built under R version 3.4.4
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.4

## 
## 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
library(stringr)

Reading data

data <- read.csv("DataCleaningExercise-Dataset1.csv",header = T,stringsAsFactors = F)
head(data)
##                Office.Title                            Office.Description
## 1 DSCC Member                 1st Representative District, Office "A"    
## 2 DSCC Member                 1st Representative District, Office "B"    
## 3 DSCC Member                 2nd Representative District, Office "A"    
## 4 DSCC Member                 2nd Representative District, Office "B"    
## 5 DSCC Member                 3rd Representative District, Office "A"    
## 6 DSCC Member                 3rd Representative District, Office "B"    
##   Office.Address.1 Office.Address.2 City State Zip.Code Office.Phone
## 1                                           LA                      
## 2                                           LA                      
## 3                                           LA                      
## 4                                           LA                      
## 5                                           LA                      
## 6                                           LA                      
##   Parish         Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1           Helen Godfrey Smith        P. O. Box 32                    
## 2                                                                      
## 3                Frances Kelley      935 Linden St.                    
## 4        Frederic D. Washington    2213 Queens Hwy.                    
## 5                Barbara Norton     3821 Morrow St.                    
## 6               "Steve" Jackson  610 Sugarleaf Trl.                    
##   Candidate.City Candidate.State Candidate.Zip.Code        Phone Ethnicity
## 1        Gilliam              LA              71029 318-296-4404         B
## 2                                                                         
## 3     Shreveport              LA         71104-4209 318-869-0355         W
## 4     Shreveport              LA         71103-4048 318-470-0403         B
## 5     Shreveport              LA         71109-7647 318-635-2923          
## 6     Shreveport              LA         71106-6332 318-347-5421         B
##   Sex Party.Code Office.Level Expiration.Date Commissioned.Date Salutation
## 1   F          D           52      02/29/2016          04-03-12           
## 2                          52                                             
## 3   F          D           52      02/29/2016          04-03-12           
## 4   M          D           52      02/29/2016          04-03-12           
## 5              D           52      02/29/2016          04-03-12           
## 6   M          D           52      02/29/2016          04-03-12
#Get NA count
detectNAs <- function(inp) {
  return(sum(is.na(inp)))
}
# get detectZeros Count
detectZeros <- function(inp) {
  if (class(inp) != "numeric") {
    return ("Non Numeric Column")
  }
  sum(inp==0)
}

# get detectSpaces Count
detectSpaces <- function(inp) {
  if (class(inp) != "character") {
    return ("Non Character Column")
  }
  sum(trimws(inp)=="")
}

# get Outlier Count
detectOutliers <- function(inp, na.rm=TRUE) {
  if (class(inp) != "numeric") {
    return ("Non Numeric Column")
  }
  i.qnt <- quantile(inp, probs=c(.25, .75), na.rm=na.rm)
  i.max <- 1.5 * IQR(inp, na.rm=na.rm)
  otp <- inp
  otp[inp < (i.qnt[1] - i.max)] <- NA
  otp[inp > (i.qnt[2] + i.max)] <- NA
  return(inp[is.na(otp)])
}
#detect NA
lapply(data,FUN = detectNAs)
## $Office.Title
## [1] 0
## 
## $Office.Description
## [1] 0
## 
## $Office.Address.1
## [1] 0
## 
## $Office.Address.2
## [1] 0
## 
## $City
## [1] 0
## 
## $State
## [1] 0
## 
## $Zip.Code
## [1] 0
## 
## $Office.Phone
## [1] 0
## 
## $Parish
## [1] 0
## 
## $Candidate.Name
## [1] 0
## 
## $Candidate.Address.1
## [1] 0
## 
## $Candidate.Address.2
## [1] 0
## 
## $Candidate.City
## [1] 0
## 
## $Candidate.State
## [1] 0
## 
## $Candidate.Zip.Code
## [1] 0
## 
## $Phone
## [1] 0
## 
## $Ethnicity
## [1] 0
## 
## $Sex
## [1] 0
## 
## $Party.Code
## [1] 0
## 
## $Office.Level
## [1] 0
## 
## $Expiration.Date
## [1] 0
## 
## $Commissioned.Date
## [1] 0
## 
## $Salutation
## [1] 0
# detect Zeros
lapply(data, FUN=detectZeros)
## $Office.Title
## [1] "Non Numeric Column"
## 
## $Office.Description
## [1] "Non Numeric Column"
## 
## $Office.Address.1
## [1] "Non Numeric Column"
## 
## $Office.Address.2
## [1] "Non Numeric Column"
## 
## $City
## [1] "Non Numeric Column"
## 
## $State
## [1] "Non Numeric Column"
## 
## $Zip.Code
## [1] "Non Numeric Column"
## 
## $Office.Phone
## [1] "Non Numeric Column"
## 
## $Parish
## [1] "Non Numeric Column"
## 
## $Candidate.Name
## [1] "Non Numeric Column"
## 
## $Candidate.Address.1
## [1] "Non Numeric Column"
## 
## $Candidate.Address.2
## [1] "Non Numeric Column"
## 
## $Candidate.City
## [1] "Non Numeric Column"
## 
## $Candidate.State
## [1] "Non Numeric Column"
## 
## $Candidate.Zip.Code
## [1] "Non Numeric Column"
## 
## $Phone
## [1] "Non Numeric Column"
## 
## $Ethnicity
## [1] "Non Numeric Column"
## 
## $Sex
## [1] "Non Numeric Column"
## 
## $Party.Code
## [1] "Non Numeric Column"
## 
## $Office.Level
## [1] "Non Numeric Column"
## 
## $Expiration.Date
## [1] "Non Numeric Column"
## 
## $Commissioned.Date
## [1] "Non Numeric Column"
## 
## $Salutation
## [1] "Non Numeric Column"
# detect Spaces
lapply(data, FUN=detectSpaces)
## $Office.Title
## [1] 0
## 
## $Office.Description
## [1] 284
## 
## $Office.Address.1
## [1] 2357
## 
## $Office.Address.2
## [1] 6862
## 
## $City
## [1] 2358
## 
## $State
## [1] 10
## 
## $Zip.Code
## [1] 2366
## 
## $Office.Phone
## [1] 2397
## 
## $Parish
## [1] 1013
## 
## $Candidate.Name
## [1] 911
## 
## $Candidate.Address.1
## [1] 911
## 
## $Candidate.Address.2
## [1] 6862
## 
## $Candidate.City
## [1] 912
## 
## $Candidate.State
## [1] 911
## 
## $Candidate.Zip.Code
## [1] 912
## 
## $Phone
## [1] 1016
## 
## $Ethnicity
## [1] 1096
## 
## $Sex
## [1] 1103
## 
## $Party.Code
## [1] 1051
## 
## $Office.Level
## [1] "Non Character Column"
## 
## $Expiration.Date
## [1] 1104
## 
## $Commissioned.Date
## [1] 966
## 
## $Salutation
## [1] 2822
# detect Outliers
lapply(data, FUN=detectOutliers)
## $Office.Title
## [1] "Non Numeric Column"
## 
## $Office.Description
## [1] "Non Numeric Column"
## 
## $Office.Address.1
## [1] "Non Numeric Column"
## 
## $Office.Address.2
## [1] "Non Numeric Column"
## 
## $City
## [1] "Non Numeric Column"
## 
## $State
## [1] "Non Numeric Column"
## 
## $Zip.Code
## [1] "Non Numeric Column"
## 
## $Office.Phone
## [1] "Non Numeric Column"
## 
## $Parish
## [1] "Non Numeric Column"
## 
## $Candidate.Name
## [1] "Non Numeric Column"
## 
## $Candidate.Address.1
## [1] "Non Numeric Column"
## 
## $Candidate.Address.2
## [1] "Non Numeric Column"
## 
## $Candidate.City
## [1] "Non Numeric Column"
## 
## $Candidate.State
## [1] "Non Numeric Column"
## 
## $Candidate.Zip.Code
## [1] "Non Numeric Column"
## 
## $Phone
## [1] "Non Numeric Column"
## 
## $Ethnicity
## [1] "Non Numeric Column"
## 
## $Sex
## [1] "Non Numeric Column"
## 
## $Party.Code
## [1] "Non Numeric Column"
## 
## $Office.Level
## [1] "Non Numeric Column"
## 
## $Expiration.Date
## [1] "Non Numeric Column"
## 
## $Commissioned.Date
## [1] "Non Numeric Column"
## 
## $Salutation
## [1] "Non Numeric Column"
data$Office.Title <- trimws(data$Office.Title)
head(data,n = 10)
##    Office.Title                            Office.Description
## 1   DSCC Member   1st Representative District, Office "A"    
## 2   DSCC Member   1st Representative District, Office "B"    
## 3   DSCC Member   2nd Representative District, Office "A"    
## 4   DSCC Member   2nd Representative District, Office "B"    
## 5   DSCC Member   3rd Representative District, Office "A"    
## 6   DSCC Member   3rd Representative District, Office "B"    
## 7   DSCC Member   4th Representative District, Office "A"    
## 8   DSCC Member   4th Representative District, Office "B"    
## 9   DSCC Member   5th Representative District, Office "A"    
## 10  DSCC Member   5th Representative District, Office "B"    
##    Office.Address.1 Office.Address.2 City State Zip.Code Office.Phone
## 1                                            LA                      
## 2                                            LA                      
## 3                                            LA                      
## 4                                            LA                      
## 5                                            LA                      
## 6                                            LA                      
## 7                                            LA                      
## 8                                            LA                      
## 9                                            LA                      
## 10                                           LA                      
##    Parish         Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1            Helen Godfrey Smith        P. O. Box 32                    
## 2                                                                       
## 3                 Frances Kelley      935 Linden St.                    
## 4         Frederic D. Washington    2213 Queens Hwy.                    
## 5                 Barbara Norton     3821 Morrow St.                    
## 6                "Steve" Jackson  610 Sugarleaf Trl.                    
## 7                  June Phillips    3761 Bobbitt Pl.                    
## 8                Larry Ferdinand     3436 Galaxy Ln.                    
## 9                    Nita Steele     P. O. Box 52691                    
## 10                    Artis Cash 119 Waters Edge Dr.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2                                                                
## 3      Shreveport              LA         71104-4209 318-869-0355
## 4      Shreveport              LA         71103-4048 318-470-0403
## 5      Shreveport              LA         71109-7647 318-635-2923
## 6      Shreveport              LA         71106-6332 318-347-5421
## 7      Shreveport              LA         71107-3801 318-221-5957
## 8      Shreveport              LA         71119-5002 318-636-1555
## 9      Shreveport              LA              71135 318-797-5604
## 10     Shreveport              LA         71106-7775 318-798-3124
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2                                     52                                  
## 3          W   F          D           52      02/29/2016          04-03-12
## 4          B   M          D           52      02/29/2016          04-03-12
## 5                         D           52      02/29/2016          04-03-12
## 6          B   M          D           52      02/29/2016          04-03-12
## 7          B   F          D           52      02/29/2016          04-03-12
## 8          B   M          D           52      02/29/2016          04-03-12
## 9          B   F          D           52      02/29/2016          04-03-12
## 10         B   M          D           52      02/29/2016          04-03-12
##       Salutation
## 1               
## 2               
## 3               
## 4               
## 5               
## 6               
## 7   Ms. Phillips
## 8  Mr. Ferdinand
## 9     Ms. Steele
## 10      Mr. Cash
data$Office.Description <- str_replace_all(data$Office.Description, pattern="[[:punct:]]", "")
data$Office.Description <- trimws(data$Office.Description,which = "both")
detectSpaces(data$Office.Description)
## [1] 284
data$Office.Description[data$Office.Description == ""] <- NA
head(data,n = 10)
##    Office.Title                   Office.Description Office.Address.1
## 1   DSCC Member 1st Representative District Office A                 
## 2   DSCC Member 1st Representative District Office B                 
## 3   DSCC Member 2nd Representative District Office A                 
## 4   DSCC Member 2nd Representative District Office B                 
## 5   DSCC Member 3rd Representative District Office A                 
## 6   DSCC Member 3rd Representative District Office B                 
## 7   DSCC Member 4th Representative District Office A                 
## 8   DSCC Member 4th Representative District Office B                 
## 9   DSCC Member 5th Representative District Office A                 
## 10  DSCC Member 5th Representative District Office B                 
##    Office.Address.2 City State Zip.Code Office.Phone Parish
## 1                           LA                             
## 2                           LA                             
## 3                           LA                             
## 4                           LA                             
## 5                           LA                             
## 6                           LA                             
## 7                           LA                             
## 8                           LA                             
## 9                           LA                             
## 10                          LA                             
##            Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1     Helen Godfrey Smith        P. O. Box 32                    
## 2                                                                
## 3          Frances Kelley      935 Linden St.                    
## 4  Frederic D. Washington    2213 Queens Hwy.                    
## 5          Barbara Norton     3821 Morrow St.                    
## 6         "Steve" Jackson  610 Sugarleaf Trl.                    
## 7           June Phillips    3761 Bobbitt Pl.                    
## 8         Larry Ferdinand     3436 Galaxy Ln.                    
## 9             Nita Steele     P. O. Box 52691                    
## 10             Artis Cash 119 Waters Edge Dr.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2                                                                
## 3      Shreveport              LA         71104-4209 318-869-0355
## 4      Shreveport              LA         71103-4048 318-470-0403
## 5      Shreveport              LA         71109-7647 318-635-2923
## 6      Shreveport              LA         71106-6332 318-347-5421
## 7      Shreveport              LA         71107-3801 318-221-5957
## 8      Shreveport              LA         71119-5002 318-636-1555
## 9      Shreveport              LA              71135 318-797-5604
## 10     Shreveport              LA         71106-7775 318-798-3124
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2                                     52                                  
## 3          W   F          D           52      02/29/2016          04-03-12
## 4          B   M          D           52      02/29/2016          04-03-12
## 5                         D           52      02/29/2016          04-03-12
## 6          B   M          D           52      02/29/2016          04-03-12
## 7          B   F          D           52      02/29/2016          04-03-12
## 8          B   M          D           52      02/29/2016          04-03-12
## 9          B   F          D           52      02/29/2016          04-03-12
## 10         B   M          D           52      02/29/2016          04-03-12
##       Salutation
## 1               
## 2               
## 3               
## 4               
## 5               
## 6               
## 7   Ms. Phillips
## 8  Mr. Ferdinand
## 9     Ms. Steele
## 10      Mr. Cash
data$Office.Address.1[data$Office.Address.1 == ""] <- NA
data$Office.Address.1 <- str_replace_all(data$Office.Address.1,pattern="[[:punct:]]", "")
head(data,n = 10)
##    Office.Title                   Office.Description Office.Address.1
## 1   DSCC Member 1st Representative District Office A             <NA>
## 2   DSCC Member 1st Representative District Office B             <NA>
## 3   DSCC Member 2nd Representative District Office A             <NA>
## 4   DSCC Member 2nd Representative District Office B             <NA>
## 5   DSCC Member 3rd Representative District Office A             <NA>
## 6   DSCC Member 3rd Representative District Office B             <NA>
## 7   DSCC Member 4th Representative District Office A             <NA>
## 8   DSCC Member 4th Representative District Office B             <NA>
## 9   DSCC Member 5th Representative District Office A             <NA>
## 10  DSCC Member 5th Representative District Office B             <NA>
##    Office.Address.2 City State Zip.Code Office.Phone Parish
## 1                           LA                             
## 2                           LA                             
## 3                           LA                             
## 4                           LA                             
## 5                           LA                             
## 6                           LA                             
## 7                           LA                             
## 8                           LA                             
## 9                           LA                             
## 10                          LA                             
##            Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1     Helen Godfrey Smith        P. O. Box 32                    
## 2                                                                
## 3          Frances Kelley      935 Linden St.                    
## 4  Frederic D. Washington    2213 Queens Hwy.                    
## 5          Barbara Norton     3821 Morrow St.                    
## 6         "Steve" Jackson  610 Sugarleaf Trl.                    
## 7           June Phillips    3761 Bobbitt Pl.                    
## 8         Larry Ferdinand     3436 Galaxy Ln.                    
## 9             Nita Steele     P. O. Box 52691                    
## 10             Artis Cash 119 Waters Edge Dr.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2                                                                
## 3      Shreveport              LA         71104-4209 318-869-0355
## 4      Shreveport              LA         71103-4048 318-470-0403
## 5      Shreveport              LA         71109-7647 318-635-2923
## 6      Shreveport              LA         71106-6332 318-347-5421
## 7      Shreveport              LA         71107-3801 318-221-5957
## 8      Shreveport              LA         71119-5002 318-636-1555
## 9      Shreveport              LA              71135 318-797-5604
## 10     Shreveport              LA         71106-7775 318-798-3124
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2                                     52                                  
## 3          W   F          D           52      02/29/2016          04-03-12
## 4          B   M          D           52      02/29/2016          04-03-12
## 5                         D           52      02/29/2016          04-03-12
## 6          B   M          D           52      02/29/2016          04-03-12
## 7          B   F          D           52      02/29/2016          04-03-12
## 8          B   M          D           52      02/29/2016          04-03-12
## 9          B   F          D           52      02/29/2016          04-03-12
## 10         B   M          D           52      02/29/2016          04-03-12
##       Salutation
## 1               
## 2               
## 3               
## 4               
## 5               
## 6               
## 7   Ms. Phillips
## 8  Mr. Ferdinand
## 9     Ms. Steele
## 10      Mr. Cash
data$Office.Address.2[data$Office.Address.2 == ""] <- NA
data$Office.Address.2 <- str_replace_all(data$Office.Address.2,pattern="[[:punct:]]", "")
head(data,n = 10)
##    Office.Title                   Office.Description Office.Address.1
## 1   DSCC Member 1st Representative District Office A             <NA>
## 2   DSCC Member 1st Representative District Office B             <NA>
## 3   DSCC Member 2nd Representative District Office A             <NA>
## 4   DSCC Member 2nd Representative District Office B             <NA>
## 5   DSCC Member 3rd Representative District Office A             <NA>
## 6   DSCC Member 3rd Representative District Office B             <NA>
## 7   DSCC Member 4th Representative District Office A             <NA>
## 8   DSCC Member 4th Representative District Office B             <NA>
## 9   DSCC Member 5th Representative District Office A             <NA>
## 10  DSCC Member 5th Representative District Office B             <NA>
##    Office.Address.2 City State Zip.Code Office.Phone Parish
## 1              <NA>         LA                             
## 2              <NA>         LA                             
## 3              <NA>         LA                             
## 4              <NA>         LA                             
## 5              <NA>         LA                             
## 6              <NA>         LA                             
## 7              <NA>         LA                             
## 8              <NA>         LA                             
## 9              <NA>         LA                             
## 10             <NA>         LA                             
##            Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1     Helen Godfrey Smith        P. O. Box 32                    
## 2                                                                
## 3          Frances Kelley      935 Linden St.                    
## 4  Frederic D. Washington    2213 Queens Hwy.                    
## 5          Barbara Norton     3821 Morrow St.                    
## 6         "Steve" Jackson  610 Sugarleaf Trl.                    
## 7           June Phillips    3761 Bobbitt Pl.                    
## 8         Larry Ferdinand     3436 Galaxy Ln.                    
## 9             Nita Steele     P. O. Box 52691                    
## 10             Artis Cash 119 Waters Edge Dr.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2                                                                
## 3      Shreveport              LA         71104-4209 318-869-0355
## 4      Shreveport              LA         71103-4048 318-470-0403
## 5      Shreveport              LA         71109-7647 318-635-2923
## 6      Shreveport              LA         71106-6332 318-347-5421
## 7      Shreveport              LA         71107-3801 318-221-5957
## 8      Shreveport              LA         71119-5002 318-636-1555
## 9      Shreveport              LA              71135 318-797-5604
## 10     Shreveport              LA         71106-7775 318-798-3124
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2                                     52                                  
## 3          W   F          D           52      02/29/2016          04-03-12
## 4          B   M          D           52      02/29/2016          04-03-12
## 5                         D           52      02/29/2016          04-03-12
## 6          B   M          D           52      02/29/2016          04-03-12
## 7          B   F          D           52      02/29/2016          04-03-12
## 8          B   M          D           52      02/29/2016          04-03-12
## 9          B   F          D           52      02/29/2016          04-03-12
## 10         B   M          D           52      02/29/2016          04-03-12
##       Salutation
## 1               
## 2               
## 3               
## 4               
## 5               
## 6               
## 7   Ms. Phillips
## 8  Mr. Ferdinand
## 9     Ms. Steele
## 10      Mr. Cash
data$City <- str_replace_all(data$Office.Address.1,pattern="[[:punct:]]", "")
data$City <- trimws(data$City)
data$City <- str_replace_all(data$City,pattern = "St+","")
data$City <- str_replace_all(data$Office.Address.1,pattern="[[:punct:]]", "")
data$City[data$City == ""] <- NA
data$City[is.na(data$City)] <- data$Candidate.City[is.na(data$City)]
data$City[data$City == ""] <- NA
data<- distinct(data,City,.keep_all = T)
head(data,n = 10)
##    Office.Title                    Office.Description Office.Address.1
## 1   DSCC Member  1st Representative District Office A             <NA>
## 2   DSCC Member  1st Representative District Office B             <NA>
## 3   DSCC Member  2nd Representative District Office A             <NA>
## 4   DSCC Member  6th Representative District Office B             <NA>
## 5   DSCC Member  7th Representative District Office A             <NA>
## 6   DSCC Member  7th Representative District Office B             <NA>
## 7   DSCC Member  8th Representative District Office B             <NA>
## 8   DSCC Member 10th Representative District Office A             <NA>
## 9   DSCC Member 11th Representative District Office A             <NA>
## 10  DSCC Member 13th Representative District Office B             <NA>
##    Office.Address.2         City State Zip.Code Office.Phone Parish
## 1              <NA>      Gilliam    LA                             
## 2              <NA>         <NA>    LA                             
## 3              <NA>   Shreveport    LA                             
## 4              <NA> Bossier City    LA                             
## 5              <NA>    Mansfield    LA                             
## 6              <NA>    Stonewall    LA                             
## 7              <NA>       Benton    LA                             
## 8              <NA>       Minden    LA                             
## 9              <NA>  Haynesville    LA                             
## 10             <NA>    Jonesboro    LA                             
##         Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1  Helen Godfrey Smith        P. O. Box 32                    
## 2                                                             
## 3       Frances Kelley      935 Linden St.                    
## 4    Lee A. Jeter, Sr.    400 Columbia Cir                    
## 5     Cynthia Williams        P.O. Box 417                    
## 6   Johnny C. McFerren  361 Linwood Avenue                    
## 7      Ronald Griffing   4512 Palmetto Rd.                    
## 8          Pattie Odom        1004 Elm St.                    
## 9          Tara Hollis      141 Adkins Pl.                    
## 10     Bobby Culpepper     4500 Walker Rd.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2                                                                
## 3      Shreveport              LA         71104-4209 318-869-0355
## 4    Bossier City              LA         71112-4268 318-230-5478
## 5       Mansfield              LA              71052 318-567-2995
## 6       Stonewall              LA         71078-9170 318-686-2291
## 7          Benton              LA         71006-9710 318-965-4797
## 8          Minden              LA              71055             
## 9     Haynesville              LA         71038-7585 318-433-1058
## 10      Jonesboro              LA         71251-5588 318-259-4184
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2                                     52                                  
## 3          W   F          D           52      02/29/2016          04-03-12
## 4          B   M          D           52      02/29/2016          04-03-12
## 5          W   F          D           52      02/29/2016          04-03-12
## 6          W   M          D           52      02/29/2016          04-03-12
## 7          W   M          D           52      02/29/2016          04-03-12
## 8                                     52                          29-10-12
## 9          W   F          D           52      02/29/2016          04-03-12
## 10         W   M          D           52      02/29/2016          04-03-12
##       Salutation
## 1               
## 2               
## 3               
## 4      Mr. Jeter
## 5   Ms. Williams
## 6   Mr. McFerren
## 7   Mr. Griffing
## 8               
## 9     Ms. Hollis
## 10 Mr. Culpepper
data$State <- trimws(data$State)
data$State[data$State ==""] <- NA
head(data,n = 10)
##    Office.Title                    Office.Description Office.Address.1
## 1   DSCC Member  1st Representative District Office A             <NA>
## 2   DSCC Member  1st Representative District Office B             <NA>
## 3   DSCC Member  2nd Representative District Office A             <NA>
## 4   DSCC Member  6th Representative District Office B             <NA>
## 5   DSCC Member  7th Representative District Office A             <NA>
## 6   DSCC Member  7th Representative District Office B             <NA>
## 7   DSCC Member  8th Representative District Office B             <NA>
## 8   DSCC Member 10th Representative District Office A             <NA>
## 9   DSCC Member 11th Representative District Office A             <NA>
## 10  DSCC Member 13th Representative District Office B             <NA>
##    Office.Address.2         City State Zip.Code Office.Phone Parish
## 1              <NA>      Gilliam    LA                             
## 2              <NA>         <NA>    LA                             
## 3              <NA>   Shreveport    LA                             
## 4              <NA> Bossier City    LA                             
## 5              <NA>    Mansfield    LA                             
## 6              <NA>    Stonewall    LA                             
## 7              <NA>       Benton    LA                             
## 8              <NA>       Minden    LA                             
## 9              <NA>  Haynesville    LA                             
## 10             <NA>    Jonesboro    LA                             
##         Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1  Helen Godfrey Smith        P. O. Box 32                    
## 2                                                             
## 3       Frances Kelley      935 Linden St.                    
## 4    Lee A. Jeter, Sr.    400 Columbia Cir                    
## 5     Cynthia Williams        P.O. Box 417                    
## 6   Johnny C. McFerren  361 Linwood Avenue                    
## 7      Ronald Griffing   4512 Palmetto Rd.                    
## 8          Pattie Odom        1004 Elm St.                    
## 9          Tara Hollis      141 Adkins Pl.                    
## 10     Bobby Culpepper     4500 Walker Rd.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2                                                                
## 3      Shreveport              LA         71104-4209 318-869-0355
## 4    Bossier City              LA         71112-4268 318-230-5478
## 5       Mansfield              LA              71052 318-567-2995
## 6       Stonewall              LA         71078-9170 318-686-2291
## 7          Benton              LA         71006-9710 318-965-4797
## 8          Minden              LA              71055             
## 9     Haynesville              LA         71038-7585 318-433-1058
## 10      Jonesboro              LA         71251-5588 318-259-4184
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2                                     52                                  
## 3          W   F          D           52      02/29/2016          04-03-12
## 4          B   M          D           52      02/29/2016          04-03-12
## 5          W   F          D           52      02/29/2016          04-03-12
## 6          W   M          D           52      02/29/2016          04-03-12
## 7          W   M          D           52      02/29/2016          04-03-12
## 8                                     52                          29-10-12
## 9          W   F          D           52      02/29/2016          04-03-12
## 10         W   M          D           52      02/29/2016          04-03-12
##       Salutation
## 1               
## 2               
## 3               
## 4      Mr. Jeter
## 5   Ms. Williams
## 6   Mr. McFerren
## 7   Mr. Griffing
## 8               
## 9     Ms. Hollis
## 10 Mr. Culpepper
data$Zip.Code[data$Zip.Code == ""] <- NA
data$Zip.Code[is.na(data$Zip.Code)] <- data$Candidate.Zip.Code[is.na(data$Zip.Code)]
data$Zip.Code[data$Zip.Code == ""] <- NA
head(data,n = 10)
##    Office.Title                    Office.Description Office.Address.1
## 1   DSCC Member  1st Representative District Office A             <NA>
## 2   DSCC Member  1st Representative District Office B             <NA>
## 3   DSCC Member  2nd Representative District Office A             <NA>
## 4   DSCC Member  6th Representative District Office B             <NA>
## 5   DSCC Member  7th Representative District Office A             <NA>
## 6   DSCC Member  7th Representative District Office B             <NA>
## 7   DSCC Member  8th Representative District Office B             <NA>
## 8   DSCC Member 10th Representative District Office A             <NA>
## 9   DSCC Member 11th Representative District Office A             <NA>
## 10  DSCC Member 13th Representative District Office B             <NA>
##    Office.Address.2         City State   Zip.Code Office.Phone Parish
## 1              <NA>      Gilliam    LA      71029                    
## 2              <NA>         <NA>    LA       <NA>                    
## 3              <NA>   Shreveport    LA 71104-4209                    
## 4              <NA> Bossier City    LA 71112-4268                    
## 5              <NA>    Mansfield    LA      71052                    
## 6              <NA>    Stonewall    LA 71078-9170                    
## 7              <NA>       Benton    LA 71006-9710                    
## 8              <NA>       Minden    LA      71055                    
## 9              <NA>  Haynesville    LA 71038-7585                    
## 10             <NA>    Jonesboro    LA 71251-5588                    
##         Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1  Helen Godfrey Smith        P. O. Box 32                    
## 2                                                             
## 3       Frances Kelley      935 Linden St.                    
## 4    Lee A. Jeter, Sr.    400 Columbia Cir                    
## 5     Cynthia Williams        P.O. Box 417                    
## 6   Johnny C. McFerren  361 Linwood Avenue                    
## 7      Ronald Griffing   4512 Palmetto Rd.                    
## 8          Pattie Odom        1004 Elm St.                    
## 9          Tara Hollis      141 Adkins Pl.                    
## 10     Bobby Culpepper     4500 Walker Rd.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2                                                                
## 3      Shreveport              LA         71104-4209 318-869-0355
## 4    Bossier City              LA         71112-4268 318-230-5478
## 5       Mansfield              LA              71052 318-567-2995
## 6       Stonewall              LA         71078-9170 318-686-2291
## 7          Benton              LA         71006-9710 318-965-4797
## 8          Minden              LA              71055             
## 9     Haynesville              LA         71038-7585 318-433-1058
## 10      Jonesboro              LA         71251-5588 318-259-4184
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2                                     52                                  
## 3          W   F          D           52      02/29/2016          04-03-12
## 4          B   M          D           52      02/29/2016          04-03-12
## 5          W   F          D           52      02/29/2016          04-03-12
## 6          W   M          D           52      02/29/2016          04-03-12
## 7          W   M          D           52      02/29/2016          04-03-12
## 8                                     52                          29-10-12
## 9          W   F          D           52      02/29/2016          04-03-12
## 10         W   M          D           52      02/29/2016          04-03-12
##       Salutation
## 1               
## 2               
## 3               
## 4      Mr. Jeter
## 5   Ms. Williams
## 6   Mr. McFerren
## 7   Mr. Griffing
## 8               
## 9     Ms. Hollis
## 10 Mr. Culpepper
data$Office.Phone <- trimws(data$Office.Phone)
data$Office.Phone[data$Office.Phone == ""] <- NA
head(data,n = 10)
##    Office.Title                    Office.Description Office.Address.1
## 1   DSCC Member  1st Representative District Office A             <NA>
## 2   DSCC Member  1st Representative District Office B             <NA>
## 3   DSCC Member  2nd Representative District Office A             <NA>
## 4   DSCC Member  6th Representative District Office B             <NA>
## 5   DSCC Member  7th Representative District Office A             <NA>
## 6   DSCC Member  7th Representative District Office B             <NA>
## 7   DSCC Member  8th Representative District Office B             <NA>
## 8   DSCC Member 10th Representative District Office A             <NA>
## 9   DSCC Member 11th Representative District Office A             <NA>
## 10  DSCC Member 13th Representative District Office B             <NA>
##    Office.Address.2         City State   Zip.Code Office.Phone Parish
## 1              <NA>      Gilliam    LA      71029         <NA>       
## 2              <NA>         <NA>    LA       <NA>         <NA>       
## 3              <NA>   Shreveport    LA 71104-4209         <NA>       
## 4              <NA> Bossier City    LA 71112-4268         <NA>       
## 5              <NA>    Mansfield    LA      71052         <NA>       
## 6              <NA>    Stonewall    LA 71078-9170         <NA>       
## 7              <NA>       Benton    LA 71006-9710         <NA>       
## 8              <NA>       Minden    LA      71055         <NA>       
## 9              <NA>  Haynesville    LA 71038-7585         <NA>       
## 10             <NA>    Jonesboro    LA 71251-5588         <NA>       
##         Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1  Helen Godfrey Smith        P. O. Box 32                    
## 2                                                             
## 3       Frances Kelley      935 Linden St.                    
## 4    Lee A. Jeter, Sr.    400 Columbia Cir                    
## 5     Cynthia Williams        P.O. Box 417                    
## 6   Johnny C. McFerren  361 Linwood Avenue                    
## 7      Ronald Griffing   4512 Palmetto Rd.                    
## 8          Pattie Odom        1004 Elm St.                    
## 9          Tara Hollis      141 Adkins Pl.                    
## 10     Bobby Culpepper     4500 Walker Rd.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2                                                                
## 3      Shreveport              LA         71104-4209 318-869-0355
## 4    Bossier City              LA         71112-4268 318-230-5478
## 5       Mansfield              LA              71052 318-567-2995
## 6       Stonewall              LA         71078-9170 318-686-2291
## 7          Benton              LA         71006-9710 318-965-4797
## 8          Minden              LA              71055             
## 9     Haynesville              LA         71038-7585 318-433-1058
## 10      Jonesboro              LA         71251-5588 318-259-4184
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2                                     52                                  
## 3          W   F          D           52      02/29/2016          04-03-12
## 4          B   M          D           52      02/29/2016          04-03-12
## 5          W   F          D           52      02/29/2016          04-03-12
## 6          W   M          D           52      02/29/2016          04-03-12
## 7          W   M          D           52      02/29/2016          04-03-12
## 8                                     52                          29-10-12
## 9          W   F          D           52      02/29/2016          04-03-12
## 10         W   M          D           52      02/29/2016          04-03-12
##       Salutation
## 1               
## 2               
## 3               
## 4      Mr. Jeter
## 5   Ms. Williams
## 6   Mr. McFerren
## 7   Mr. Griffing
## 8               
## 9     Ms. Hollis
## 10 Mr. Culpepper
data$Parish <- str_replace_all(data$Parish,pattern="[[:punct:]]", "")
data$Parish <- str_replace_all(data$Parish,pattern="St+", "")
data$Parish <- trimws(data$Parish)
data$Parish[data$Parish == ""] <- NA
data <- distinct(data,Parish,.keep_all = T)
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish        Candidate.Name Candidate.Address.1
## 1        <NA>   Helen Godfrey Smith        P. O. Box 32
## 2      ACADIA         "Steve" Barry 451 Pointe Noir Rd.
## 3       ALLEN        Jonathan Jones      812 Pawnee Rd.
## 4   ASCENSION          "L.C." Irvin        P.O. Box 353
## 5  ASSUMPTION       Patrick Lawless       139 Ideal St.
## 6   AVOYELLES      Douglas Anderson    527 Highway 1183
## 7  BEAUREGARD      Brian S. Lestage        P.O. Box 100
## 8   BIENVILLE        Roy Lilly, Jr.       P. O. Box 730
## 9     BOSSIER Julian C. Whittington   226 Ward Line Rd.
## 10      CADDO  Michael D. Hall, Sr.   3232 Bluebird Ln.
##    Candidate.Address.2 Candidate.City Candidate.State Candidate.Zip.Code
## 1                             Gilliam              LA              71029
## 2                              Branch              LA         70516-3506
## 3                            Glenmora              LA         71433-4800
## 4                              Darrow              LA              70725
## 5                          Belle Rose              LA              70341
## 6                          Simmesport              LA         71369-2309
## 7                            DeRidder              LA              70634
## 8                            Gibsland              LA              71028
## 9                              Benton              LA         71006-8630
## 10                         Keithville              LA         71047-7380
##           Phone Ethnicity Sex Party.Code Office.Level Expiration.Date
## 1  318-296-4404         B   F          D           52      02/29/2016
## 2  337-684-2787         W   M          R           64      02/29/2016
## 3  318-335-3750         W   M          D           54      02/29/2016
## 4  225-473-9261         B   M          D           54      02/29/2016
## 5  985-369-2074         B   M          D           56      02/29/2016
## 6  318-941-2857         W   M          D          225      06/30/2016
## 7  337-463-8595         W   M          R          230      06/30/2016
## 8  318-843-6557         W   M          D           54      02/29/2016
## 9  318-326-5972         W   M          R          225      06/30/2016
## 10 318-218-5691         B   M          D           56      02/29/2016
##    Commissioned.Date  Salutation
## 1           04-03-12            
## 2           04-03-12   Ms. Barry
## 3           04-03-12   Mr. Jones
## 4           04-03-12   Mr. Irvin
## 5           04-03-12 Mr. Lawless
## 6           07-01-12            
## 7           07-01-12            
## 8           04-03-12   Mr. Lilly
## 9           07-01-12            
## 10          04-03-12    Mr. Hall
data$Candidate.Name <- str_replace_all(data$Candidate.Name,pattern="[[:punct:]]", "")
data$Candidate.Name <- trimws(data$Candidate.Name)
data$Candidate.Name[data$Candidate.Name == ""] <- NA
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish       Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1        <NA>  Helen Godfrey Smith        P. O. Box 32                    
## 2      ACADIA          Steve Barry 451 Pointe Noir Rd.                    
## 3       ALLEN       Jonathan Jones      812 Pawnee Rd.                    
## 4   ASCENSION             LC Irvin        P.O. Box 353                    
## 5  ASSUMPTION      Patrick Lawless       139 Ideal St.                    
## 6   AVOYELLES     Douglas Anderson    527 Highway 1183                    
## 7  BEAUREGARD      Brian S Lestage        P.O. Box 100                    
## 8   BIENVILLE         Roy Lilly Jr       P. O. Box 730                    
## 9     BOSSIER Julian C Whittington   226 Ward Line Rd.                    
## 10      CADDO    Michael D Hall Sr   3232 Bluebird Ln.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2          Branch              LA         70516-3506 337-684-2787
## 3        Glenmora              LA         71433-4800 318-335-3750
## 4          Darrow              LA              70725 225-473-9261
## 5      Belle Rose              LA              70341 985-369-2074
## 6      Simmesport              LA         71369-2309 318-941-2857
## 7        DeRidder              LA              70634 337-463-8595
## 8        Gibsland              LA              71028 318-843-6557
## 9          Benton              LA         71006-8630 318-326-5972
## 10     Keithville              LA         71047-7380 318-218-5691
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2          W   M          R           64      02/29/2016          04-03-12
## 3          W   M          D           54      02/29/2016          04-03-12
## 4          B   M          D           54      02/29/2016          04-03-12
## 5          B   M          D           56      02/29/2016          04-03-12
## 6          W   M          D          225      06/30/2016          07-01-12
## 7          W   M          R          230      06/30/2016          07-01-12
## 8          W   M          D           54      02/29/2016          04-03-12
## 9          W   M          R          225      06/30/2016          07-01-12
## 10         B   M          D           56      02/29/2016          04-03-12
##     Salutation
## 1             
## 2    Ms. Barry
## 3    Mr. Jones
## 4    Mr. Irvin
## 5  Mr. Lawless
## 6             
## 7             
## 8    Mr. Lilly
## 9             
## 10    Mr. Hall
data$Ethnicity <- as.factor(data$Ethnicity)
data$Ethnicity[data$Ethnicity == ""] <- NA
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish       Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1        <NA>  Helen Godfrey Smith        P. O. Box 32                    
## 2      ACADIA          Steve Barry 451 Pointe Noir Rd.                    
## 3       ALLEN       Jonathan Jones      812 Pawnee Rd.                    
## 4   ASCENSION             LC Irvin        P.O. Box 353                    
## 5  ASSUMPTION      Patrick Lawless       139 Ideal St.                    
## 6   AVOYELLES     Douglas Anderson    527 Highway 1183                    
## 7  BEAUREGARD      Brian S Lestage        P.O. Box 100                    
## 8   BIENVILLE         Roy Lilly Jr       P. O. Box 730                    
## 9     BOSSIER Julian C Whittington   226 Ward Line Rd.                    
## 10      CADDO    Michael D Hall Sr   3232 Bluebird Ln.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2          Branch              LA         70516-3506 337-684-2787
## 3        Glenmora              LA         71433-4800 318-335-3750
## 4          Darrow              LA              70725 225-473-9261
## 5      Belle Rose              LA              70341 985-369-2074
## 6      Simmesport              LA         71369-2309 318-941-2857
## 7        DeRidder              LA              70634 337-463-8595
## 8        Gibsland              LA              71028 318-843-6557
## 9          Benton              LA         71006-8630 318-326-5972
## 10     Keithville              LA         71047-7380 318-218-5691
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2          W   M          R           64      02/29/2016          04-03-12
## 3          W   M          D           54      02/29/2016          04-03-12
## 4          B   M          D           54      02/29/2016          04-03-12
## 5          B   M          D           56      02/29/2016          04-03-12
## 6          W   M          D          225      06/30/2016          07-01-12
## 7          W   M          R          230      06/30/2016          07-01-12
## 8          W   M          D           54      02/29/2016          04-03-12
## 9          W   M          R          225      06/30/2016          07-01-12
## 10         B   M          D           56      02/29/2016          04-03-12
##     Salutation
## 1             
## 2    Ms. Barry
## 3    Mr. Jones
## 4    Mr. Irvin
## 5  Mr. Lawless
## 6             
## 7             
## 8    Mr. Lilly
## 9             
## 10    Mr. Hall
data$Sex <- as.factor(data$Sex)
data$Sex[data$Sex == ""] <- NA
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish       Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1        <NA>  Helen Godfrey Smith        P. O. Box 32                    
## 2      ACADIA          Steve Barry 451 Pointe Noir Rd.                    
## 3       ALLEN       Jonathan Jones      812 Pawnee Rd.                    
## 4   ASCENSION             LC Irvin        P.O. Box 353                    
## 5  ASSUMPTION      Patrick Lawless       139 Ideal St.                    
## 6   AVOYELLES     Douglas Anderson    527 Highway 1183                    
## 7  BEAUREGARD      Brian S Lestage        P.O. Box 100                    
## 8   BIENVILLE         Roy Lilly Jr       P. O. Box 730                    
## 9     BOSSIER Julian C Whittington   226 Ward Line Rd.                    
## 10      CADDO    Michael D Hall Sr   3232 Bluebird Ln.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2          Branch              LA         70516-3506 337-684-2787
## 3        Glenmora              LA         71433-4800 318-335-3750
## 4          Darrow              LA              70725 225-473-9261
## 5      Belle Rose              LA              70341 985-369-2074
## 6      Simmesport              LA         71369-2309 318-941-2857
## 7        DeRidder              LA              70634 337-463-8595
## 8        Gibsland              LA              71028 318-843-6557
## 9          Benton              LA         71006-8630 318-326-5972
## 10     Keithville              LA         71047-7380 318-218-5691
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2          W   M          R           64      02/29/2016          04-03-12
## 3          W   M          D           54      02/29/2016          04-03-12
## 4          B   M          D           54      02/29/2016          04-03-12
## 5          B   M          D           56      02/29/2016          04-03-12
## 6          W   M          D          225      06/30/2016          07-01-12
## 7          W   M          R          230      06/30/2016          07-01-12
## 8          W   M          D           54      02/29/2016          04-03-12
## 9          W   M          R          225      06/30/2016          07-01-12
## 10         B   M          D           56      02/29/2016          04-03-12
##     Salutation
## 1             
## 2    Ms. Barry
## 3    Mr. Jones
## 4    Mr. Irvin
## 5  Mr. Lawless
## 6             
## 7             
## 8    Mr. Lilly
## 9             
## 10    Mr. Hall
data$Party.Code <- as.factor(data$Party.Code)
data$Party.Code[data$Party.Code == ""] <- NA
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish       Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1        <NA>  Helen Godfrey Smith        P. O. Box 32                    
## 2      ACADIA          Steve Barry 451 Pointe Noir Rd.                    
## 3       ALLEN       Jonathan Jones      812 Pawnee Rd.                    
## 4   ASCENSION             LC Irvin        P.O. Box 353                    
## 5  ASSUMPTION      Patrick Lawless       139 Ideal St.                    
## 6   AVOYELLES     Douglas Anderson    527 Highway 1183                    
## 7  BEAUREGARD      Brian S Lestage        P.O. Box 100                    
## 8   BIENVILLE         Roy Lilly Jr       P. O. Box 730                    
## 9     BOSSIER Julian C Whittington   226 Ward Line Rd.                    
## 10      CADDO    Michael D Hall Sr   3232 Bluebird Ln.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2          Branch              LA         70516-3506 337-684-2787
## 3        Glenmora              LA         71433-4800 318-335-3750
## 4          Darrow              LA              70725 225-473-9261
## 5      Belle Rose              LA              70341 985-369-2074
## 6      Simmesport              LA         71369-2309 318-941-2857
## 7        DeRidder              LA              70634 337-463-8595
## 8        Gibsland              LA              71028 318-843-6557
## 9          Benton              LA         71006-8630 318-326-5972
## 10     Keithville              LA         71047-7380 318-218-5691
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2          W   M          R           64      02/29/2016          04-03-12
## 3          W   M          D           54      02/29/2016          04-03-12
## 4          B   M          D           54      02/29/2016          04-03-12
## 5          B   M          D           56      02/29/2016          04-03-12
## 6          W   M          D          225      06/30/2016          07-01-12
## 7          W   M          R          230      06/30/2016          07-01-12
## 8          W   M          D           54      02/29/2016          04-03-12
## 9          W   M          R          225      06/30/2016          07-01-12
## 10         B   M          D           56      02/29/2016          04-03-12
##     Salutation
## 1             
## 2    Ms. Barry
## 3    Mr. Jones
## 4    Mr. Irvin
## 5  Mr. Lawless
## 6             
## 7             
## 8    Mr. Lilly
## 9             
## 10    Mr. Hall
data$Office.Level[data$Office.Level == ""] <- NA 
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish       Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1        <NA>  Helen Godfrey Smith        P. O. Box 32                    
## 2      ACADIA          Steve Barry 451 Pointe Noir Rd.                    
## 3       ALLEN       Jonathan Jones      812 Pawnee Rd.                    
## 4   ASCENSION             LC Irvin        P.O. Box 353                    
## 5  ASSUMPTION      Patrick Lawless       139 Ideal St.                    
## 6   AVOYELLES     Douglas Anderson    527 Highway 1183                    
## 7  BEAUREGARD      Brian S Lestage        P.O. Box 100                    
## 8   BIENVILLE         Roy Lilly Jr       P. O. Box 730                    
## 9     BOSSIER Julian C Whittington   226 Ward Line Rd.                    
## 10      CADDO    Michael D Hall Sr   3232 Bluebird Ln.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2          Branch              LA         70516-3506 337-684-2787
## 3        Glenmora              LA         71433-4800 318-335-3750
## 4          Darrow              LA              70725 225-473-9261
## 5      Belle Rose              LA              70341 985-369-2074
## 6      Simmesport              LA         71369-2309 318-941-2857
## 7        DeRidder              LA              70634 337-463-8595
## 8        Gibsland              LA              71028 318-843-6557
## 9          Benton              LA         71006-8630 318-326-5972
## 10     Keithville              LA         71047-7380 318-218-5691
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2          W   M          R           64      02/29/2016          04-03-12
## 3          W   M          D           54      02/29/2016          04-03-12
## 4          B   M          D           54      02/29/2016          04-03-12
## 5          B   M          D           56      02/29/2016          04-03-12
## 6          W   M          D          225      06/30/2016          07-01-12
## 7          W   M          R          230      06/30/2016          07-01-12
## 8          W   M          D           54      02/29/2016          04-03-12
## 9          W   M          R          225      06/30/2016          07-01-12
## 10         B   M          D           56      02/29/2016          04-03-12
##     Salutation
## 1             
## 2    Ms. Barry
## 3    Mr. Jones
## 4    Mr. Irvin
## 5  Mr. Lawless
## 6             
## 7             
## 8    Mr. Lilly
## 9             
## 10    Mr. Hall
data$Expiration.Date <- trimws(data$Expiration.Date)
data$Expiration.Date[data$Expiration.Date == ""] <- NA
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish       Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1        <NA>  Helen Godfrey Smith        P. O. Box 32                    
## 2      ACADIA          Steve Barry 451 Pointe Noir Rd.                    
## 3       ALLEN       Jonathan Jones      812 Pawnee Rd.                    
## 4   ASCENSION             LC Irvin        P.O. Box 353                    
## 5  ASSUMPTION      Patrick Lawless       139 Ideal St.                    
## 6   AVOYELLES     Douglas Anderson    527 Highway 1183                    
## 7  BEAUREGARD      Brian S Lestage        P.O. Box 100                    
## 8   BIENVILLE         Roy Lilly Jr       P. O. Box 730                    
## 9     BOSSIER Julian C Whittington   226 Ward Line Rd.                    
## 10      CADDO    Michael D Hall Sr   3232 Bluebird Ln.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2          Branch              LA         70516-3506 337-684-2787
## 3        Glenmora              LA         71433-4800 318-335-3750
## 4          Darrow              LA              70725 225-473-9261
## 5      Belle Rose              LA              70341 985-369-2074
## 6      Simmesport              LA         71369-2309 318-941-2857
## 7        DeRidder              LA              70634 337-463-8595
## 8        Gibsland              LA              71028 318-843-6557
## 9          Benton              LA         71006-8630 318-326-5972
## 10     Keithville              LA         71047-7380 318-218-5691
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2          W   M          R           64      02/29/2016          04-03-12
## 3          W   M          D           54      02/29/2016          04-03-12
## 4          B   M          D           54      02/29/2016          04-03-12
## 5          B   M          D           56      02/29/2016          04-03-12
## 6          W   M          D          225      06/30/2016          07-01-12
## 7          W   M          R          230      06/30/2016          07-01-12
## 8          W   M          D           54      02/29/2016          04-03-12
## 9          W   M          R          225      06/30/2016          07-01-12
## 10         B   M          D           56      02/29/2016          04-03-12
##     Salutation
## 1             
## 2    Ms. Barry
## 3    Mr. Jones
## 4    Mr. Irvin
## 5  Mr. Lawless
## 6             
## 7             
## 8    Mr. Lilly
## 9             
## 10    Mr. Hall
data$Commissioned.Date <- trimws(data$Commissioned.Date)
data$Commissioned.Date[data$Commissioned.Date== ""] <- NA
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish       Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1        <NA>  Helen Godfrey Smith        P. O. Box 32                    
## 2      ACADIA          Steve Barry 451 Pointe Noir Rd.                    
## 3       ALLEN       Jonathan Jones      812 Pawnee Rd.                    
## 4   ASCENSION             LC Irvin        P.O. Box 353                    
## 5  ASSUMPTION      Patrick Lawless       139 Ideal St.                    
## 6   AVOYELLES     Douglas Anderson    527 Highway 1183                    
## 7  BEAUREGARD      Brian S Lestage        P.O. Box 100                    
## 8   BIENVILLE         Roy Lilly Jr       P. O. Box 730                    
## 9     BOSSIER Julian C Whittington   226 Ward Line Rd.                    
## 10      CADDO    Michael D Hall Sr   3232 Bluebird Ln.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2          Branch              LA         70516-3506 337-684-2787
## 3        Glenmora              LA         71433-4800 318-335-3750
## 4          Darrow              LA              70725 225-473-9261
## 5      Belle Rose              LA              70341 985-369-2074
## 6      Simmesport              LA         71369-2309 318-941-2857
## 7        DeRidder              LA              70634 337-463-8595
## 8        Gibsland              LA              71028 318-843-6557
## 9          Benton              LA         71006-8630 318-326-5972
## 10     Keithville              LA         71047-7380 318-218-5691
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2          W   M          R           64      02/29/2016          04-03-12
## 3          W   M          D           54      02/29/2016          04-03-12
## 4          B   M          D           54      02/29/2016          04-03-12
## 5          B   M          D           56      02/29/2016          04-03-12
## 6          W   M          D          225      06/30/2016          07-01-12
## 7          W   M          R          230      06/30/2016          07-01-12
## 8          W   M          D           54      02/29/2016          04-03-12
## 9          W   M          R          225      06/30/2016          07-01-12
## 10         B   M          D           56      02/29/2016          04-03-12
##     Salutation
## 1             
## 2    Ms. Barry
## 3    Mr. Jones
## 4    Mr. Irvin
## 5  Mr. Lawless
## 6             
## 7             
## 8    Mr. Lilly
## 9             
## 10    Mr. Hall
data$Salutation <- str_replace_all(data$Salutation,pattern="[[:punct:]]", "")                      
data$Salutation <- str_replace_all(data$Salutation,pattern = "Sr","")
data$Salutation <- str_replace_all(data$Salutation,pattern = "Jr","")
data$Salutation[data$Salutation == ""] <- NA
head(data,n = 10)
##      Office.Title                   Office.Description  Office.Address.1
## 1     DSCC Member 1st Representative District Office A              <NA>
## 2     RPEC Member                             at Large              <NA>
## 3     DPEC Member                             at Large              <NA>
## 4     DPEC Member                             at Large              <NA>
## 5     DPEC Member                           District 1              <NA>
## 6         Sheriff                                 <NA> 675 Government St
## 7  Clerk of Court                                 <NA>       P O Box 100
## 8     DPEC Member                             at Large              <NA>
## 9         Sheriff                                 <NA>       P O Box 850
## 10    DPEC Member                          District 11              <NA>
##    Office.Address.2              City State   Zip.Code Office.Phone
## 1              <NA>           Gilliam    LA      71029         <NA>
## 2              <NA>            Branch    LA 70516-3506         <NA>
## 3              <NA>          Glenmora    LA 71433-4800         <NA>
## 4              <NA>            Darrow    LA      70725         <NA>
## 5              <NA>        Belle Rose    LA      70341         <NA>
## 6              <NA> 675 Government St    LA      71351 318-253-4000
## 7              <NA>       P O Box 100    LA      70634 337-463-8595
## 8              <NA>          Gibsland    LA      71028         <NA>
## 9              <NA>       P O Box 850    LA      71006 318-965-3410
## 10             <NA>        Keithville    LA 71047-7380         <NA>
##        Parish       Candidate.Name Candidate.Address.1 Candidate.Address.2
## 1        <NA>  Helen Godfrey Smith        P. O. Box 32                    
## 2      ACADIA          Steve Barry 451 Pointe Noir Rd.                    
## 3       ALLEN       Jonathan Jones      812 Pawnee Rd.                    
## 4   ASCENSION             LC Irvin        P.O. Box 353                    
## 5  ASSUMPTION      Patrick Lawless       139 Ideal St.                    
## 6   AVOYELLES     Douglas Anderson    527 Highway 1183                    
## 7  BEAUREGARD      Brian S Lestage        P.O. Box 100                    
## 8   BIENVILLE         Roy Lilly Jr       P. O. Box 730                    
## 9     BOSSIER Julian C Whittington   226 Ward Line Rd.                    
## 10      CADDO    Michael D Hall Sr   3232 Bluebird Ln.                    
##    Candidate.City Candidate.State Candidate.Zip.Code        Phone
## 1         Gilliam              LA              71029 318-296-4404
## 2          Branch              LA         70516-3506 337-684-2787
## 3        Glenmora              LA         71433-4800 318-335-3750
## 4          Darrow              LA              70725 225-473-9261
## 5      Belle Rose              LA              70341 985-369-2074
## 6      Simmesport              LA         71369-2309 318-941-2857
## 7        DeRidder              LA              70634 337-463-8595
## 8        Gibsland              LA              71028 318-843-6557
## 9          Benton              LA         71006-8630 318-326-5972
## 10     Keithville              LA         71047-7380 318-218-5691
##    Ethnicity Sex Party.Code Office.Level Expiration.Date Commissioned.Date
## 1          B   F          D           52      02/29/2016          04-03-12
## 2          W   M          R           64      02/29/2016          04-03-12
## 3          W   M          D           54      02/29/2016          04-03-12
## 4          B   M          D           54      02/29/2016          04-03-12
## 5          B   M          D           56      02/29/2016          04-03-12
## 6          W   M          D          225      06/30/2016          07-01-12
## 7          W   M          R          230      06/30/2016          07-01-12
## 8          W   M          D           54      02/29/2016          04-03-12
## 9          W   M          R          225      06/30/2016          07-01-12
## 10         B   M          D           56      02/29/2016          04-03-12
##    Salutation
## 1        <NA>
## 2    Ms Barry
## 3    Mr Jones
## 4    Mr Irvin
## 5  Mr Lawless
## 6        <NA>
## 7        <NA>
## 8    Mr Lilly
## 9        <NA>
## 10    Mr Hall

<<< End Of Report >>>