Learn R Programming

igraph (version 1.3.5)

running_mean: Running mean of a time series

Description

running_mean calculates the running mean in a vector with the given bin width.

Usage

running_mean(v, binwidth)

Value

A numeric vector of length length(v)-binwidth+1

Arguments

v

The numeric vector.

binwidth

Numeric constant, the size of the bin, should be meaningful, ie. smaller than the length of v.

Author

Gabor Csardi csardi.gabor@gmail.com

Details

The running mean of v is a w vector of length length(v)-binwidth+1. The first element of w id the average of the first binwidth elements of v, the second element of w is the average of elements 2:(binwidth+1), etc.

Examples

Run this code

running_mean(1:100, 10)

Run the code above in your browser using DataLab