R/make_correct.R

#' Correct vehicle make names
#'
#' Given a vehicle make name this function will produce the correct make name that
#' could be processed in S1 without being treated as make 'Other'.
#'
#' @param make Character string indicating vehicle make name
#'
#' @return Character string indicating corrected vehicle make name that is suited for S1
#'
#' @export
#'
#' @examples
#' make_correct('TOYOTA')
make_correct <- function(make) {
  make_s1 <- ''

  if (make %in% c('ACURA')) {make_s1 <- 'Acura'}
  else if (make %in% c('BUICK')) {make_s1 <- 'Buick'}
  else if (make %in% c('Cherolet', 'CHEVROLET')) {make_s1 <- 'Chevrolet'}
  else if (make %in% c('CHRYSLER')) {make_s1 <- 'Chrysler'}
  else if (make %in% c('DODGE')) {make_s1 <- 'Dodge'}
  else if (make %in% c('FORD')) {make_s1 <- 'Ford'}
  else if (make %in% c('HONDA')) {make_s1 <- 'Honda'}
  else if (str_detect(make, regex('^hyu|^hyn', ignore_case = TRUE))) {make_s1 <-'Hyundai'}
  else if (make %in% c('JEEP')) {make_s1 <-'Jeep'}
  else if (make %in% c('KIA', 'Kio')) {make_s1 <-'Kia'}
  else if (make %in% c('LEXUS')) {make_s1 <-'Lexus'}
  else if (make %in% c('MAZDA')) {make_s1 <-'Mazda'}
  else if (make %in% c("Mistubishi", "MITS", "Mitsubihi", "MITSUBISHI",
                           "MITSUBUSHI", "Mitsubisi", "Mitubishi")) {
    make_s1 <-'Mitsubishi'
  }
  else if (make %in% c('Nissa', 'NISSAN')) {make_s1 <-'Nissan'}
  else if (make %in% c('RAM')) {make_s1 <-'Ram'}
  else if (make %in% c('SCION')) {make_s1 <-'Scion'}
  else if (str_detect(make, regex('^suz', ignore_case = TRUE))) {make_s1 <-'Suzuki'}
  else if (make %in% c('TOYOA', 'TOYOTA')) {make_s1 <-'Toyota'}
  else {make_s1 <-make}

  return(make_s1)
}
hongqi0314/PRAuto.PMML documentation built on May 6, 2019, 11:30 a.m.