R/dataMunging.R

Defines functions replaceNAs

Documented in replaceNAs

#' REPLACE NAs BY ANOTHER VALUE IN A DATA.TABLE
#'
#' @param x is a `data.table`
#' @param val is the value to replace NAs for. By default, it looks
#'  for and replaces 0s
#'
#' @export
#'
#' @return a `data.table`
#'
#' @importFrom data.table data.table

replaceNAs <- function(x, val = 0) {
  x[is.na(x)] <- val
  x
}
CeresBarros/ToolsCB documentation built on Aug. 23, 2024, 4:22 p.m.