Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cumulative mean #256

Closed
Tracked by #250
spsanderson opened this issue Sep 19, 2022 · 0 comments · Fixed by #269
Closed
Tracked by #250

cumulative mean #256

spsanderson opened this issue Sep 19, 2022 · 0 comments · Fixed by #269
Assignees
Labels
enhancement New feature or request

Comments

@spsanderson
Copy link
Owner

spsanderson commented Sep 19, 2022

Function:

#' Cumulative Mean
#' 
#' @family Vector Function
#' 
#' @author Steven P. Sanderson II, MPH
#' 
#' @details
#' A function to return the cumulative mean of a vector. It uses [dplyr::cummean()]
#' as the basis of the function.
#' 
#' @description 
#' A function to return the cumulative mean of a vector.
#' 
#' @parm .x A numeric vector
#' 
#' @examples 
#' x <- mtcars$mpg
#' 
#' cmean(x)
#' 
#' @return 
#' A numeric vector
#' 
#' @export
#' 

cmean <- function(.x){
  dplyr::cummean(.x)
}

Example:

x <- mtcars$mpg
> cmean(x)
 [1] 21.00000 21.00000 21.60000 21.55000 20.98000 20.50000 19.61429 20.21250
 [9] 20.50000 20.37000 20.13636 19.82500 19.63077 19.31429 18.72000 18.20000
[17] 17.99412 18.79444 19.40526 20.13000 20.19524 19.98182 19.77391 19.50417
[25] 19.49200 19.79231 20.02222 20.39286 20.23448 20.21667 20.04839 20.09062
@spsanderson spsanderson self-assigned this Sep 19, 2022
@spsanderson spsanderson added the enhancement New feature or request label Sep 19, 2022
@spsanderson spsanderson added this to the TidyDensity 1.2.3 milestone Sep 19, 2022
spsanderson added a commit that referenced this issue Sep 19, 2022
Fixes #256
Fixes #257
Fixes #258
Fixes #260
Fixes #265
Fixes #266
Fixes #267
Fixes #268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

1 participant