-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat (WIP): Mean age of childbearing #61
base: master
Are you sure you want to change the base?
Conversation
Could maybe use this for example test data https://www.measureevaluation.org/prh/rh_indicators/family-planning/fertility/total-fertility-rate |
#' @param dt \[`data.table()`\]\cr A data.table with columns 'age_start', | ||
#' 'age_end', and a column of fertility rates named after `nfx_col`. | ||
#' @param nfx_col \[`character(1)`\]\cr Name of fertility rate column in `dt`. | ||
#' Defualts to "nfx". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we should use standard notation nfx
in other functions instead of asfr
.
#' @param nfx_col \[`character(1)`\]\cr Name of fertility rate column in `dt`. | ||
#' Defualts to "nfx". | ||
#' @inheritParams gen_lifetable_parameters | ||
#' @param value_col \[`character(1)`\]\cr Name of output 'MACB' column. Defaults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would you not just want this to be mcab
? We don't have this option in other functions.
#' | ||
#' @export | ||
#' | ||
#' @examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add example(s)
assertthat::is.string(nfx_col), | ||
assertthat::is.string(value_col) | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add more checks for dt
and id_cols
.
|
||
macb_dt <- dt[ | ||
, | ||
.(macb = weighted.mean((age_end + age_start) / 2, get(nfx_col))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to use list
instead of .
in the packages. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the weighted.mean
function come from?
#' | ||
#' @return \[`data.table()`\] A data.table with calculated 'MACB' for each | ||
#' unique grouping in `id_cols`, stored in `value_col`. | ||
#' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add @details
section with equation?
#' @param dt \[`data.table()`\]\cr A data.table with columns 'age_start', | ||
#' 'age_end', and a column of fertility rates named after `nfx_col`. | ||
#' @param nfx_col \[`character(1)`\]\cr Name of fertility rate column in `dt`. | ||
#' Defualts to "nfx". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error
#' @inheritParams gen_lifetable_parameters | ||
#' @param value_col \[`character(1)`\]\cr Name of output 'MACB' column. Defaults | ||
#' to "mcab" | ||
#' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could add @seealso
for where to find more information on MACB
Describe changes
Adds a function
macb_from_nfx()
, which calculates mean age of childbearing.What issues are related
Fixes #60
Related to #19
Checklist
Packages Repositories
ihmeuw-demographics
R packages?devtools::check()
locally?devtools::document()
?ihmeuw-demographics
code style?docker-base
ordocker-internal
? If so follow directions in those repositories to rebuild and redeploy the images.Other Repositories
README.md
, script headers, wiki pages, internal IHME hub pages etc.)?ihmeuw-demographics
team replicate or use your work using available documentation?Details of PR
Include other information helpful for reviewers.