nutrientPiePlot: Visualize the main foods contributing to the intake levels of...

View source: R/Visualization_functions.R

nutrientPiePlotR Documentation

Visualize the main foods contributing to the intake levels of a nutrient

Description

This function generates a pie-chart of the main foods contributing to the intake levels of a nutrient, based on the output from the function dietBalance().

Usage

nutrientPiePlot(daily_intake, nutrient_name = "Vitamin B-12 (ug)", n = 10)

Arguments

daily_intake

list generated with the function dietBalance().

nutrient_name

character vector indicating the name of the nutrient of interest (e.g. "Vitamin B-12 (ug)".

n

maximum number of foods to be displayed.

Value

A pie-chart showing the contribution (as percentage) of each food to the intake level of a given nutrient.

Examples

## Load data
data(food_composition_data)
data(NHI_nutrient_recommendations)
data(nutrient_group)
data(sample_diet_USDA) ## contains an example of a one-week diet

## Get daily intake
balanceF <- dietBalance(my_daily_food = sample_diet_USDA,
                        food_database = "USDA", age = 27, gender = "female")

## Generate plots
nutrientPiePlot(daily_intake = balanceF, nutrient_name = "Fiber, total dietary (g)")
nutrientPiePlot(daily_intake = balanceF, nutrient_name = "Magnesium, Mg (mg)")
nutrientPiePlot(daily_intake = balanceF, nutrient_name = "Calcium, Ca (mg)")
nutrientPiePlot(daily_intake = balanceF, nutrient_name = "Niacin (mg)")

NutrienTrackeR documentation built on July 26, 2023, 5:22 p.m.