nafill: methods to substitute NAs. Use the function na.approx from...

View source: R/utility_tools.R

nafillR Documentation

methods to substitute NAs. Use the function na.approx from package zoo.

Description

collection of imputation procedures

Usage

nafill(v, rule, maxgap = 4, verbose = F)

Arguments

v

vector with missing elements.

rule

rule for filling the missing cells. "zero" just fills them with 0; "linear" interpolate using zoo::na.approx. In this case, the tails are not filled. If "arima", then it interpolates using linear and extrapolates using arima (calling AlertTools::temp.predict)

maxgap

maximum number of consecutive NAs to fill. Longer gaps will be left unchanged. Only works for rule = "zero" or "linear"

Value

vector

Examples

# Interpolation:
v <- c(1,2,3,NA,5,6,NA,NA,9,10,NA,NA)
nafill(v, rule = "zero")
nafill(v, rule = "linear")
# Inter using linear and Extrapolation using arima
cliSBCB <- getWU(station = "SBCB")
summary(cliSBCB)
cliSBCB <- getWU(station = "SBCB") %>%
          mutate(nafill("temp_min", rule = "arima")) 

AlertaDengue/AlertTools documentation built on Nov. 27, 2024, 11:55 p.m.