gfLinInt: Imputation of small data gaps by linear interpolation

View source: R/gfLinInt.R

gfLinIntR Documentation

Imputation of small data gaps by linear interpolation

Description

This function fills small data gaps occurring in (eco-)climatological measurement series by simple linear interpolation.

Usage

gfLinInt(data, prm = "TEMP", limit = 5, width = 11, ...)

Arguments

data

Object of class ki.data. See as.ki.data, gsod2ki for further information.

prm

Character, default is "TEMP". Parameter(s) to fill.

limit

Numeric, default is 5. Maximum gap length to be filled by linear interpolation.

width

Numeric, default is 11. See rollapply for further information.

...

Additional arguments. Currently not in use.

Value

An object of class ki.data.

Author(s)

Florian Detsch

See Also

rollapply

Examples

## Not run: 
moshi <- subset(gsodstations, `STATION NAME` == "MOSHI")

gsod_moshi <- dlGsodStations(usaf = moshi$USAF,
                             start_year = 1990, end_year = 1995,
                             dsn = tempdir(),
                             unzip = TRUE)

# Conversion to KiLi SP1 `ki.data` object
ki_moshi <- gsod2ki(data = gsod_moshi,
                    prm_col = c("TEMP", "MIN", "MAX"),
                    df2ki = TRUE)

# Fill small gaps (n <= 3) by linear interpolation
ki_moshi_lf <- gfLinInt(data = ki_moshi,
                        prm = c("TEMP", "MIN", "MAX"),
                        limit = 3, width = 7)

plot(methods::slot(ki_moshi_lf, "Parameter")$TEMP, type = "l", col = "red")
lines(methods::slot(ki_moshi, "Parameter")$TEMP) 

## End(Not run)


environmentalinformatics-marburg/GSODTools documentation built on Jan. 5, 2024, 12:19 a.m.