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

Description Usage Arguments Value Examples

View source: R/utility_tools.R

Description

collection of imputation procedures

Usage

1
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

1
2
3
4
5
6
7
8
9
# 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")) 

claudia-codeco/AlertTools documentation built on Aug. 12, 2021, 9:58 a.m.