Learn R Programming

treemisc (version 0.0.1)

cummean: Cumulative means

Description

Returns a vector whose elements are the cumulative means of the argument.

Usage

cummean(x)

Value

A vector of the same length and type as x (after coercion). Names are preserved.

An NA value in x causes the corresponding and following elements of the return value to be NA, as does integer overflow (with a warning).

Arguments

x

A numeric object.

Examples

Run this code
x <- 1:10
cummean(x)
cumsum(x) / seq_along(x)  # equivalent using cumulative sums

Run the code above in your browser using DataLab