h_weightedsum: Weighted sum of time-series

h_weightedsumR Documentation

Weighted sum of time-series

Description

The function only works on the common period of the files without NA values. It operates weighted sums on one or several time-series. It is also possible to add a constant.

Usage

h_weightedsum(files, weights, constant = 0)

Arguments

files

List of file names to proceed

weights

List of weights (must have the same length as files)

constant

Constant to add (default = 0)

Details

For averaging n time-series one can use n weights wit a value of 1/n and constant = 0.

Value

The function returns + n hts files with the extracted common period + 1 hts file named as the first file of the list with the prefix w_. The sensor id is automatically set to "weighted".

Author(s)

P. Chevallier - Oct 2017-Oct 2021

Examples

## Not run: 

# choose time-series f1, f2, f3
f1 <- "foo1.hts" ; f2 <- "foo2.hts" ; f3 <- "foo3.hts"
# the new f time-series contains records f[i] = f1[i] - (0.5 * f2[i]) + (0.5 * f3[i]) + 5
f <- h_weightedsum(c(f1,f2,f3), c(1,-0.5,0.5)), 5)
# the new f time-series contains records f[i] = (1.12 * f1[i]) + 3
f <- h_weightedsum(f1, 1.12, 3)

## End(Not run)


htsr documentation built on Oct. 13, 2023, 5:10 p.m.