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

finished refactor food group score #8

Closed
wants to merge 5 commits into from
Closed

Conversation

nicholustintzaw
Copy link
Collaborator

refactor code: created food group consumption score and performed check(). No error in refactored code, but I noticed 3 warnings and 1 note.

#' 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
Copy link
Member

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
Copy link
Member

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.

R/food_group_score.R Outdated Show resolved Hide resolved
################################################################################

# Breast milk
fg_breastmilk <- function(q4, age){
Copy link
Member

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?

Copy link
Member

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
}

Copy link
Member

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()

Copy link
Member

@ernestguevarra ernestguevarra left a 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.

@nicholustintzaw
Copy link
Collaborator Author

@ernestguevarra finished all refactoring work. has one error and one warning sign that I can't solve.

@nicholustintzaw
Copy link
Collaborator Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants