-
Notifications
You must be signed in to change notification settings - Fork 0
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
finished refactor food group score #8
Conversation
#' practices meet the minimum requirement of dietary diversity (at least 5 food | ||
#' group out of 8 food groups) | ||
#' | ||
#' @param age This parameter holds the information about child age in the month |
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.
Make this clear that this is a numeric vector. R doesn't recognise a "decimal format". This is an ODK concept.
R/detect_mdd.R
Outdated
#' If this was generated from the calculation based on the child's date of birth, | ||
#' the decimal class of the variable would be the decimal numeric format. | ||
#' | ||
#' @param food_score continuous variables indicate child consumed number of food |
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.
State that this is an integer vector, not as a continuous - we don't really use the term continuous in R.
################################################################################ | ||
|
||
# Breast milk | ||
fg_breastmilk <- function(q4, age){ |
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.
why do we need the age argument in all these functions here?
is is possible for us to create one universal generic function that can score any combination of foods to be equal to 1 or 0?
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.
aggregate()
function
x should be a list()
x <- list(organ_meat, meat, insect, fish)
score_foods <- function(x) {
y <- sum(x, na.rm = TRUE)
if (y > 0) score <- 1 else score <- 0
score
}
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.
You don't have to export this function and it can be a miscellaneous function/helper function:
for package users, they need to use this approach: riycf:::score_foods()
bur for package developer, they can use this function within the package like this: scrore_foods()
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.
We can discuss my comments during our call.
@ernestguevarra finished all refactoring work. has one error and one warning sign that I can't solve. |
@ernestguevarra, I fixed the dummy_var error. Just push for documentation purposes. Please, do not review it till early next week. I will be going to re-factor again on the NA issue with Age limitation and finish the test file for all function packages this weekend. |
refactor code: created food group consumption score and performed check(). No error in refactored code, but I noticed 3 warnings and 1 note.