R/for_parallel.R

Defines functions replace.missing

Documented in replace.missing

#' (Internal) Replace missing values with other values,internally used for
#' parallelization
#'
#' @param X An input vector
#' @param missing A charactors representing a missing value
#' @param rep A vector of new values to replace missing values
#'
#' @return A vector with replaced values
#'
replace.missing <- function(X,missing=NA,rep){
  if (is.na(missing)){
    idx = which(is.na(X))
    X[idx] = rep[idx]
  }else{
    idx = which(X == missing)
    X[idx] = rep[idx]
  }
  return(X)
}

Try the KRIS package in your browser

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

KRIS documentation built on Jan. 21, 2021, 5:08 p.m.