1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utility_functions.R
\name{na2zero}
\alias{na2zero}
\title{Convert NA's to zero in data.table}
\usage{
na2zero(DT, vars = NULL)
}
\arguments{
\item{DT}{\code{data.table} object}
\item{vars}{a character string vector of variables names in \code{DT};
if \code{NULL}, uses all variable names in \code{DT}}
}
\value{
A copy of \code{DT} where \code{NA} values have been replaced with zero.
}
\description{
Given a \verb{data.table DT}, replaces any \code{NA} values
in the variables given in \code{vars} in \code{DT}. Takes a copy of the
original data and returns the modified copy.
}
\details{
Given a \code{data.table} object, converts \code{NA} values
to numeric (double) zeros for all variables named in \code{vars} or
all variables if \code{vars = NULL}.
}
\author{
Joonas Miettinen
}
|