Brian Carlton
19 June 2015
Here is the point value for a serving of some Light Butter Popcorn from a US label.
calcPoints <- function(protein, carbohydrates, fat, fiber, country){
if(country=="US") {
max(round(protein/10.9375 + carbohydrates/9.2105 + fat/3.8889 - fiber/12.5, 0))
} else {
max(round(protein/10.9375 + carbohydrates/9.2105 + fat/3.8889 + fiber/35, 0))
}}
calcPoints(5, 36, 8, 6, "US")
[1] 6