% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/na.r
\name{na.refill}
\alias{na.refill}
\title{Refill the NAs for a 'na.action' Object}
\usage{
na.refill(object, ...)
}
\arguments{
\item{object}{a \link{na.action} object (atomic vector, matrix or data.frame).}

\item{...}{further arguments special methods could require.}
}
\value{
vector, matrix or data.frame with the indices from \code{na.action}
refilled with \code{NA}s. \link{rownames} and \link{colnames} are preserved.

If the object given is not of those types, or not a \code{na.action} object,
it is returned unchanged.
}
\description{
For a \link{na.action} object, use the indices of where \code{NA}s were removed
to refill the object back to its original size with \code{NA}s in the
appropriate positions.
}
\details{
For objects where \link{na.omit} removes whole rows (e.g., matrices,
data.frames), the information about that row is lost, so \code{na.refill}
will refill those \strong{entire rows} with \code{NA}s.
}
\examples{
x <- c(1, 2, NA, 4, NA, 6)
na_x <- na.omit(x)
na_x
na.refill(na_x)

m <- matrix(1:9, 3, 3)
m[c(1, 3), 1:2] <- NA
dimnames(m) <- list(c("r1", "r2", "r3"), c("a", "b", "c"))
na_m <- na.omit(m)
na_m
na.refill(na_m) # previous data in NA row is lost

df <- data.frame(x = 1:5, y = c("a", NA, "c", "d", NA))
na_df <- na.omit(df)
na_df
na.refill(na_df)
}
\seealso{
\link{na.action}, \link{na.omit}
}
