R/NaFillTs.R

Defines functions NaFillTs

Documented in NaFillTs

#' @title NaFill
#' @param x 
#' @return filled x 
#' @author Thomas Laepple
#' @export
NaFillTs <- function(x) {
    if (sum(is.na(x)) == 0) 
        return(x)
    nonMissing <- !is.na(x)
    temp <- approx(c(time(x))[nonMissing], c(x)[nonMissing], 
        c(time(x)), rule = 2)$y
    return(ts(temp, start = start(x), deltat = deltat(x)))
}
EarthSystemDiagnostics/paleospec documentation built on Feb. 17, 2024, 4:36 p.m.