Description Usage Arguments Value Examples
The function calculates nutrient value based on a list of ingredients and their weight in grams.
1 | calculate_nutrients(ingredients, grams)
|
ingredients |
is a vector of one or more ingredients |
grams |
is a vector of the corresponding weight in grams of each ingredient |
a data frame containing the nutrients of each ingredient along with a total score.
1 2 3 4 5 6 7 8 9 | library(NutrientData)
library(dplyr)
ingredients <- c("CABBAGE,RAW", "MAYONNAISE,RED FAT,W/ OLIVE OIL", "ONIONS,RAW")
grams <- c(100, 20, 10)
calculate_nutrients(ingredients, grams) %>%
select(Food = 1, Calories = 3, Protein = 4,
Fat = 5, Carbs = 7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.