gr_fill_gaps {grwat} | R Documentation |
Fill missing daily data
Description
Use the function to fill the missing daily data by linear interpolation. These can be both missing dates and missing runoff or temperature values. A preliminary summary of missing data can be viewed by gr_get_gaps()
Usage
gr_fill_gaps(hdata, autocorr = 0.7, nobserv = NULL)
Arguments
hdata |
|
autocorr |
Autocorrelation value that defines possible length of the period that can be filled. Defaults to 0.7. If |
nobserv |
Maximum number of contiguous observations that can be interpolated. Defaults to |
Value
data.frame
which is a filled version of hdata
Examples
library(grwat)
library(dplyr)
# example Spas-Zagorye data is included with grwat package
path = system.file("extdata", "spas-zagorye.txt",
package = "grwat")
hdata_raw = read.delim(path, header = FALSE,
sep = ' ', na.strings = c('-999', '-999.0', '-'),
col.names = c('d', 'm', 'y', 'q'))
hdata = hdata_raw %>%
transmute(Date = lubridate::make_date(y, m, d),
Q = q)
head(hdata)
# identify gaps
gr_get_gaps(hdata)
# fill gaps
fhdata = gr_fill_gaps(hdata, autocorr = 0.8)
# check the results
gr_get_gaps(fhdata)
# fill gaps
fhdata = gr_fill_gaps(hdata, nobserv = 7)
# check the results
gr_get_gaps(fhdata)