1\name{na.fill} 2\alias{na.fill} 3\alias{na.fill0} 4\alias{na.fill.ts} 5\alias{na.fill.zoo} 6\alias{na.fill.default} 7\title{Fill NA or specified positions.} 8\description{ 9Generic function for filling \code{NA} values or specified positions. 10} 11\usage{ 12na.fill(object, fill, \dots) 13\method{na.fill}{ts}(object, fill, ix, \dots) 14\method{na.fill}{zoo}(object, fill, ix, \dots) 15\method{na.fill}{default}(object, fill, ix, \dots) 16 17na.fill0(object, fill, ix = !is.na(object)) 18} 19\arguments{ 20 \item{object}{an object.} 21 \item{fill}{a three component list or a vector that is coerced to a 22 list. Shorter objects are recycled. The three components 23 represent the fill value to the left of the data, within the 24 interior of the data and to the right of the data, 25 respectively. The value of any component may be the keyword 26 \code{"extend"} to indicate repetition of the 27 leftmost or rightmost non-NA value or linear interpolation in the interior. 28 \code{NULL} means that items are dropped rather than filled.} 29 \item{ix}{logical. Should be the same length as the number of time points. 30 Indicates which time points not to fill. This defaults to the non-NA values.} 31 \item{\dots}{further arguments passed to methods.} 32} 33 34\details{ 35 \code{na.fill} is a generic function for filling \code{NA} or indicated values. 36 It currently has methods for the time series classes \code{"zoo"} and \code{"ts"} 37 and a default method based on the \code{"zoo"} method. 38 39 Furthermore, \code{na.fill0} works with plain vectors and \code{"Date"} objects. 40 It also works with \code{"zoo"} objects provided that no \code{fill} component is \code{NULL}. 41} 42 43\seealso{\code{\link{na.approx}}} 44 45\examples{ 46 47z <- zoo(c(NA, 2, NA, 1, 4, 5, 2, NA)) 48na.fill(z, "extend") 49na.fill(z, c("extend", NA)) 50na.fill(z, -(1:3)) 51na.fill(z, list(NA, NULL, NA)) 52 53} 54\keyword{ts} 55