interpolate {hydroToolkit}R Documentation

Interpolation

Description

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

Usage

interpolate(df, miss_table, threshold, method = "linear")

Arguments

df

data frame with two columns: 'Date' or 'POSIXct' class in the first column and a numeric variable in the second one.

miss_table

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

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

A data frame with date and the interpolated numeric variable.

Examples

# Create BDHI hydro-met station
guido <- create_hydroMet(class_name = 'BDHI')

# List with meteorological variables (slots in BDHI's object)
cargar <- list('precip', 'Qmd', 'Qmm')

# Now assign as names the files
hydro_files   <- list.files( system.file('extdata', package = "hydroToolkit"), pattern = 'Guido' )
names(cargar) <- hydro_files

# Build the object with the met records
guido <- build_hydroMet(obj = guido, slot_list = cargar, 
               path = system.file('extdata', package = "hydroToolkit") )
               
# Get mean daily discharge and report miss data
Qmd  <- get_hydroMet(obj = guido, name = 'Qmd')[[1]]
miss <- report_miss_data(df = Qmd)

# Now interpolate miss values 
Qmd_fill <- interpolate(df = Qmd, miss_table = miss, threshold = 5, method = "linear")


[Package hydroToolkit version 0.1.0 Index]