library(oce)
m <- matrix(1:20, nrow = 5)
# Example 1: interpolate past across gaps of width/height equal to 1
m[2, 3] <- NA
m[3, 3] <- NA
m[4, 2] <- NA
m
fillGapMatrix(m)
# Example 2: cannot interpolate across larger groups by default
m <- matrix(1:20, nrow = 5)
m[2:3, 2:3] <- NA
m
fillGapMatrix(m)
# Example 3: increasing gap lets us cover gaps of size 1 or 2
fillGapMatrix(m, fillgap = 2)
Run the code above in your browser using DataLab