`cummean()` function from dplyr not providing results as expected

Viewed 239

I just want to make sure I am understanding this correctly. So I have this small vector x where the long(er) way is giving me the results as expected but dplyr cummean() is not. I am using version 1.0.0. I have tried reading documentation and searching other guides online but it's almost non-existant. Is this what is expected of cummean()? If yes, what are the values that go into this function for the resulting output?

library(tidyverse)
x <- 1:5

# long(er) way
cumsum(x) / seq_along(x)
#> [1] 1.0 1.5 2.0 2.5 3.0

# dplyr cummean()
cummean(x)
#> [1] 1.000000 1.000000 1.333333 1.750000 2.200000

Created on 2020-05-31 by the reprex package (v0.3.0)

1 Answers

Just to close this question:

This was a bug in dplyr 1.0.0 which has been solved, see GitHub tidyverse/dplyr #5325.

This error does not encounter in dplyr version 1.0.2, currently on CRAN

Related