diff --git a/NAMESPACE b/NAMESPACE index b8829e4..a9157c2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ S3method(summary,fastLink) export(aggregateEM) export(calcMoversPriors) +export(cleanAddressUSPS) export(clusterMatch) export(dedupeMatches) export(emlinkMARmov) diff --git a/R/cleanAddressUSPS.R b/R/cleanAddressUSPS.R new file mode 100644 index 0000000..9742e01 --- /dev/null +++ b/R/cleanAddressUSPS.R @@ -0,0 +1,37 @@ +#' cleanAddressUSPS +#' +#' Apply USPS address standardization to address field. +#' +#' @usage cleanAddressUSPS(address.field) +#' @param address.field A vector containing address information to be cleaned. +#' +#' @return \code{cleanAddressUSPS()} returns a cleaned version of \code{address.field}. +#' +#' @author Ted Enamorado and Ben Fifield +#' @examples dfA$streetname <- cleanAddressUSPS(dfA$streetname) +#' @export +cleanAddressUSPS <- function(address.field){ + + ## Standardization + address.field <- ifelse(grepl(" avenue", address.field), + gsub(" avenue", " ave", address.field), + ifelse(grepl(" avn", address.field), + gsub(" avn", " ave", address.field), + gsub(" av ", " ave", address.field))) + address.field <- gsub(" boulevard", " blvd", address.field) + address.field <- gsub(" circle", " cir", address.field) + address.field <- gsub(" court", " ct", address.field) + address.field <- gsub(" drive", " dr", address.field) + address.field <- gsub(" junction", " jct", address.field) + address.field <- gsub(" place", " pl", address.field) + address.field <- gsub(" road", " rd", address.field) + address.field <- gsub(" route", " rte", address.field) + address.field <- gsub(" square", " sq", address.field) + address.field <- gsub(" street", " st", address.field) + address.field <- gsub(" apartment", " apt", address.field) + address.field <- gsub(" building", " bldg", address.field) + + return(trimws(address.field)) + +} + diff --git a/man/cleanAddressUSPS.Rd b/man/cleanAddressUSPS.Rd new file mode 100644 index 0000000..aa0efdd --- /dev/null +++ b/man/cleanAddressUSPS.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cleanAddressUSPS.R +\name{cleanAddressUSPS} +\alias{cleanAddressUSPS} +\title{cleanAddressUSPS} +\usage{ +cleanAddressUSPS(address.field) +} +\arguments{ +\item{address.field}{A vector containing address information to be cleaned.} +} +\value{ +\code{cleanAddressUSPS()} returns a cleaned version of \code{address.field}. +} +\description{ +Apply USPS address standardization to address field. +} +\examples{ +dfA$streetname <- cleanAddressUSPS(dfA$streetname) +} +\author{ +Ted Enamorado and Ben Fifield +} +