This function calculates a simple rolling mean in base R. It is useful for calculating route characteristics such as mean distances of segments and changes in gradient.
See also
Other route_funs:
route_average_gradient()
,
route_rolling_diff()
,
route_rolling_gradient()
,
route_sequential_dist()
,
route_slope_matrix()
,
route_slope_vector()
Examples
y <- od_data_routes$elevations[od_data_routes$route_number == 2]
y
#> [1] 112.5263 111.0000 106.5000 84.0000 96.6250 110.0000 107.1429 105.5556
route_rolling_average(y)
#> [1] NA 110.00877 100.50000 95.70833 96.87500 104.58929 107.56614
#> [8] NA
route_rolling_average(y, n = 1)
#> [1] 112.5263 111.0000 106.5000 84.0000 96.6250 110.0000 107.1429 105.5556
route_rolling_average(y, n = 2)
#> [1] 111.7632 108.7500 95.2500 90.3125 103.3125 108.5714 106.3492 NA
route_rolling_average(y, n = 3)
#> [1] NA 110.00877 100.50000 95.70833 96.87500 104.58929 107.56614
#> [8] NA