cummean: Cumulative mean values

Description Usage Arguments Value Author(s) See Also Examples

View source: R/cummean.R

Description

Returns a vector whose i'th element is the cumulative mean (arithmetic mean) of the i'th first elements of the argument.

Usage

1

Arguments

x

a numeric vector.

Value

A vector of length length(x) with the cumulative mean. The i'th entry cummean(x)[i] equals mean(x[1:i]).

Author(s)

Anders Ellern Bilgrau <anders.ellern.bilgrau@gmail.com>

See Also

cumsum

Examples

1
2
x <- sort(rnorm(100))
GMCM:::cummean(x)

Example output

  [1] -2.04148493 -2.00801673 -1.93223125 -1.88609639 -1.83333015 -1.77238535
  [7] -1.72714791 -1.69133187 -1.63991432 -1.59271945 -1.55134999 -1.51489381
 [13] -1.47768917 -1.44352275 -1.41155201 -1.37791780 -1.34564212 -1.31689353
 [19] -1.28945225 -1.26463500 -1.24052921 -1.21837110 -1.19768123 -1.17643533
 [25] -1.15654737 -1.13817898 -1.12044615 -1.10327866 -1.08503404 -1.06471247
 [31] -1.04365570 -1.02345854 -1.00428111 -0.98616849 -0.96877591 -0.95109264
 [37] -0.93413005 -0.91641742 -0.89880931 -0.88131155 -0.86435039 -0.84741916
 [43] -0.83073482 -0.81430866 -0.79818518 -0.78260514 -0.76685409 -0.75171123
 [49] -0.73586339 -0.72039120 -0.70539095 -0.69085972 -0.67520851 -0.66011533
 [55] -0.64463423 -0.62949846 -0.61464230 -0.60003787 -0.58581798 -0.57189456
 [61] -0.55805821 -0.54459158 -0.53067080 -0.51702407 -0.50360750 -0.49030502
 [67] -0.47693548 -0.46382145 -0.45064039 -0.43758718 -0.42411563 -0.41047709
 [73] -0.39707046 -0.38399582 -0.37099566 -0.35825632 -0.34529265 -0.33212721
 [79] -0.31928028 -0.30667486 -0.29407624 -0.28045319 -0.26697420 -0.25361069
 [85] -0.23990257 -0.22525052 -0.21054866 -0.19615409 -0.18189766 -0.16744004
 [91] -0.15323137 -0.13590697 -0.11884096 -0.10130552 -0.08384497 -0.06472423
 [97] -0.04334217 -0.01696063  0.01008575  0.03676037

GMCM documentation built on Nov. 6, 2019, 1:08 a.m.