Learn R Programming

zoo (version 1.7-13)

na.fill: Fill NA or specified positions.

Description

Generic function for filling NA values or specified positions.

Usage

na.fill(object, fill, ...) "na.fill"(object, fill, ix, ...) "na.fill"(object, fill, ix, ...) "na.fill"(object, fill, ix, ...)

Arguments

object
an object.
fill
a three component list or a vector that is coerced to a list. Shorter objects are recycled. The three components represent the fill value to the left of the data, within the interior of the data and to the right of the data, respectively. The value of any component may be the keyword "extend" to indicate repetition of the leftmost or rightmost non-NA value or linear interpolation in the interior. NULL means that items are dropped rather than filled.
ix
logical. Should be the same length as the number of time points. Indicates which time points not to fill. This defaults to the non-NA values.
...
further arguments passed to methods.

Details

Fill NA or indicated values.

See Also

na.approx

Examples

Run this code

z <- zoo(c(NA, 2, NA, 1, 4, 5, 2, NA))
na.fill(z, "extend")
na.fill(z, c("extend", NA))
na.fill(z, -(1:3))
na.fill(z, list(NA, NULL, NA))

Run the code above in your browser using DataLab