R/BioCG_cat_Missing.r

Defines functions BioCG_cat_Missing

Documented in BioCG_cat_Missing

#' Name NA to something

#' @export

BioCG_cat_Missing <- function(x,the_name = "Missing"){

  if(!is.null(levels(x))){
    old_level <- levels(x)
    x <- as.vector(x)
    x[is.na(x)] <- the_name
    x <- factor(x,levels = c(old_level,the_name))}
  else if(is.null(levels(x))){
    x <- as.vector(x)
    x[is.na(x)] <- the_name
  }

  return(x)
}
AndrewH6/BioCG documentation built on Dec. 17, 2021, 8:50 a.m.