blob: 5c3a4ea370170dc234d5d4ecd56e060490b24802 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# Calculate a time weighted average concentration
The moving average is built only using the values in the past, so the
earliest possible time for the maximum in the time series returned is
after one window has passed.
## Usage
``` r
twa(x, window = 21)
# S3 method for class 'one_box'
twa(x, window = 21)
```
## Arguments
- x:
An object of type
[one_box](https://pkgdown.jrwb.de/pfm/reference/one_box.md)
- window:
The size of the moving window
## See also
[`max_twa`](https://pkgdown.jrwb.de/pfm/reference/max_twa.md)
## Examples
``` r
pred <- sawtooth(one_box(10),
applications = data.frame(time = c(0, 7), amount = c(1, 1)))
max_twa(pred)
#> $max
#> parent
#> 0.9537545
#>
#> $window_start
#> parent
#> 0
#>
#> $window_end
#> parent
#> 21
#>
```
|