Calculate your nutrients with my new package: NutrientData

nutrients

I have created a new package: NutrientData

This package contains data sets with the composition of Foods: Raw, Processed, Prepared. The source of the data is the USDA National Nutrient Database for Standard Reference, Release 28 (2015), a long with two functions to search and calculate nutrients.

You download it from github:
devtools::install_github("56north/NutrientData")

Lets first have a look at the the top 20 calorie dense foods

library(NutrientData)
library(dplyr)

data("ABBREV") # Load the data

ABBREV %>% # Select the data
arrange(-Energ_Kcal) %>% # Sort by calories per 100 g
select(Food = Shrt_Desc, Calories = Energ_Kcal) %>% # Select relevant columns
slice(1:20) %>% # Choose the top 20

If you want to search for a specific ingredient you use the “search_ingredient” function. Lets search for raw onions:

search_ingredient("onion,raw")

You can also calculate the nutrient composition of several foods, like a simple yet delicious cabbage salad:

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) %>% # Select only a few variables for looks and rename

Dinner is served. I look forward to your feedback! And if anyone is up for it, then this is a package that is just begging for cool visualizations for nutrient composition along with a Shiny overlay.!