% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/na.r
\name{setNA}
\alias{setNA}
\alias{setNA<-}
\title{Set given indices as NA}
\usage{
setNA(x, indices)

setNA(x) <- value
}
\arguments{
\item{x}{an \strong{R} object.}

\item{indices}{integer vector of indices to set as \code{NA}.}

\item{value}{integer vector of indices to set as \code{NA} for the replacement
function.}
}
\value{
the modified object with given indices set to \code{NA}.
}
\description{
For given \code{indices}, set those indices of an object as \code{NA}.
}
\details{
This function is a S3 generic. The default method sets indices
to \code{NA} using \verb{[<-}, passing the indices first to \code{\link{arrayInd}}
if the input has a non-\code{NULL} \code{dim} attribute.

The \verb{setNA<-} function is meant to be a direct replacement for \verb{is.na<-}
with (in my opinion) a clearer naming convention. The base methods are
implemented verbatim (for \link{factor} and \link{numeric_version} objects),
whereas the default method differs by using \code{arrayInd} (see above),
whereas \verb{is.na<-} is implemented just as \code{x[value] <- NA}.
}
\note{
Complex inputs will have indices set to \code{NA_complex_}, meaning that
both the real and imaginary parts will be set to \code{NA}, not just the
real part which can happen (depending on \strong{R} version) with
\code{x_complex[indices] <- NA}.
}
\examples{
setNA(1:5, c(1, 4))
setNA(c("hi", "hello", "bye", "goodbye"), c(1, 4))
setNA(matrix(1:4, 2, 2), c(1, 4))
setNA(list(1, 2, 3, list(1, 2)), c(1, 4))

x <- 1:10
setNA(x) <- c(1, 7, 9)
x
}
\seealso{
\code{\link{is.na<-}}, \link{whichNA}
}
