avg_adj: calculate average of vector elements adjacent to and...

View source: R/utils.R

avg_adjR Documentation

calculate average of vector elements adjacent to and excluding the index element

Description

Calculate average of vector elements adjacent to and excluding the index element. For example, the second element of the result is the average of the first and third elements of the input vector x. Used by smooth_age_5_zigzag_inner(), and possibly useful elsewhere.

Usage

avg_adj(x)

Arguments

x

numeric vector

Details

Tails are given a value of NA.

Value

numeric vector the same length as x.

Examples

x <- 1:10
all(avg_adj(x) == x, na.rm = TRUE)

timriffe/DemoTools documentation built on Jan. 28, 2024, 5:13 a.m.