R/miss_ind.R

#' Generate missing indicator
#'
#' Generate missing indicator as a new feature
#'
#' @param feature Vector of float numbers representing attribute that miss indicator
#'                based on.
#' @param missCode Float number indicating missing status.
#' @param newFieldName Character string used to name generated indicator.
#'
#' @return Vector of 0 and 1's, where 1 means missing and 0 otherwise.
#'
#' @export
#'
#' @examples
#' missFICO_UsedPlat <- miss_ind(feature = Data_UsedPlat$FICO, missCode = 0,
#'     newFieldName = 'FICO')
miss_ind <- function(feature, missCode = 0, newFieldName) {
  missInd <- as.data.frame( ifelse(feature == missCode, 1, 0) )
  names(missInd) <- paste0("miss", newFieldName)
  return(missInd)
}
hongqi0314/PRAuto.PMML documentation built on May 6, 2019, 11:30 a.m.