| fill.gap {oce} | R Documentation |
Fill a gap in an oce object
fill.gap(x, start, end, column)
x |
an oce object. |
start |
the start of the bad section of data (see details). |
end |
the start of the bad section of data (see details). |
column |
if provided, the name of the column referred to by
start and end. |
Gaps in the data (i.e. columns in x$data) are filled by
linear interpolation between the start and end points.
If column is not provided, then start and end are
indices. If column is provided, then start and
end refer to values in the named column.
A new oce object.
Dan Kelley
library(oce)
data(pt)
# mess up a day
d <- pt
d$data$temperature[as.POSIXct("2008-06-27", tz="UTC")<=d$data$time & d$data$time <= as.POSIXct("2008-06-28", tz="UTC")] <- 20
plot(d, which=1)
# fix that day by linear interpolation
dd <- fill.gap(d, as.POSIXct("2008-06-27", tz="UTC"), as.POSIXct("2008-06-28", tz="UTC"), "time")
lines(dd$data$time, dd$data$temperature, col="red")