R/nona.R

Defines functions nona

Documented in nona

#' No NAs
#'
#' Converts NAs to 0s
#' @param vec Required. Character or Numeric vector. 
#' @return Character vector.
#' @export
#' @examples
#' x <- c(NA, 1, 0); nona(x)
#' x <- c(NA, "dk", 0); nona(x)

nona <- function(vec = NULL) {
  
  if (is.null(vec)) {
    stop("Input vector cannot be NULL")
  }
  
  vec[is.na(vec)] <- 0
  vec
}

Try the guess package in your browser

Any scripts or data that you put into this service are public.

guess documentation built on Dec. 16, 2025, 1:07 a.m.