calculate_nutrients: Calculates nutrients

Description Usage Arguments Value Examples

Description

The function calculates nutrient value based on a list of ingredients and their weight in grams.

Usage

1
calculate_nutrients(ingredients, grams)

Arguments

ingredients

is a vector of one or more ingredients

grams

is a vector of the corresponding weight in grams of each ingredient

Value

a data frame containing the nutrients of each ingredient along with a total score.

Examples

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)

56north/NutrientData documentation built on May 5, 2019, 10:45 a.m.