View source: R/Visualization_functions.R
nutrientPiePlot | R Documentation |
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().
nutrientPiePlot(daily_intake, nutrient_name = "Vitamin B-12 (ug)", n = 10)
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. |
A pie-chart showing the contribution (as percentage) of each food to the intake level of a given nutrient.
## 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)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.