interpolate {hydrotoolbox}R Documentation

Interpolation

Description

This function applies interpolation to fill in missing (or non-recorded) values.

Usage

interpolate(
  x,
  col_name,
  out_name = NULL,
  miss_table,
  threshold,
  method = "linear"
)

Arguments

x

data frame with class Date or POSIX* in the first column and numeric on the others.

col_name

string with column name of the series to interpolate.

out_name

optional. String with new column name. If you set it as NULL, the function will overwrite the original data frame.

miss_table

data frame with three columns: first and last date of interpolation (first and second column respectively). The last and third column, is of class numeric with the number of steps to interpolate. See report_miss.

threshold

numeric variable with the maximum number of dates in which to apply the interpolation.

method

string with the interpolation method. In this version only 'linear' method is allowed.

Value

The same data frame but with interpolated values.

Examples


# read cuevas station file
path <- system.file('extdata', 'ianigla_cuevas.csv',
        package = 'hydrotoolbox')

cuevas <- read_ianigla(path = path)

# get the miss_table
miss_data <- report_miss(x = cuevas, col_name = 'Irradiancia')[[1]]

# apply interpolation function when gap is less than 3 hours
cuevas_interpo <- interpolate(x = cuevas,
                              col_name = 'Irradiancia',
                              out_name = 'kin_interpo',
                              miss_table = miss_data,
                              threshold = 3)

report_miss(x = cuevas_interpo,
            col_name = c('Irradiancia', 'kin_interpo'))



[Package hydrotoolbox version 1.1.2 Index]