Title: Score and Plot the Healthy Eating Index from NHANES Data
Version: 0.1.4
Description: Calculate and visualize Healthy Eating Index (HEI) scores from National Health and Nutrition Examination Survey 24-hour dietary recall data utilizing three methods recommended by the National Cancer Institute (2024) <https://epi.grants.cancer.gov/hei/hei-methods-and-calculations.html#:~:text=To%20use%20the%20simple%20HEI,the%20total%20scores%20across%20individuals.>. Effortlessly analyze HEI scores across different demographic groups and years.
License: MIT + file LICENSE
URL: https://github.com/abhrastat/heiscore
BugReports: https://github.com/abhrastat/heiscore/issues
Depends: R (≥ 2.10)
Imports: dplyr, fmsb, ggplot2, ggpubr, graphics, grDevices, magrittr, rlang, shiny, shinythemes, shinyWidgets, stats, stringr, tibble, tidyr, utils, viridis
Encoding: UTF-8
RoxygenNote: 7.3.1
NeedsCompilation: no
Packaged: 2024-09-25 03:48:59 UTC; vijetharamdas
Author: Vijetha Ramdas [aut, cre], Berkeley Ho [aut], Abhra Sarkar [aut]
Maintainer: Vijetha Ramdas <vramdas06@gmail.com>
Repository: CRAN
Date/Publication: 2024-09-26 22:20:06 UTC

Plot Healthy Eating Index (HEI) scores from NHANES data

Description

This function plots HEI component or total scores using the inputted scoring method and graph type. The user can subset the data to only include subjects in specific demographic groups

Usage

plotScore(
  graph = NULL,
  method,
  years,
  component,
  demo = NULL,
  sex = c("Female", "Male"),
  race = c("Asian", "White", "Black", "Other", "Mexican American", "Other Hispanic"),
  age = c(2, 100),
  income = c("[0, 5000)", "[5000, 10000)", "[10000, 15000)", "[15000, 20000)",
    "[20000, 25000)", "[25000, 35000)", "[35000, 45000)", "[45000, 55000)",
    "[55000, 65000)", "[65000, 75000)", "75000+", "[75000, 100000)", ">100000", ">20000",
    "<20000", "Refused", "Don't know", "NA")
)

Arguments

graph

A single character string with the desired graph type. Choose "histogram" when method = "simple". Choose "bar" when method = "pop ratio" or "mean ratio" and component is not "total score". Choose "bar" or "radar" when method = "pop ratio" or "mean ratio" and component = "total score"

method

A single character string with the HEI scoring method to use. Choose from "simple", "pop ratio", or "mean ratio".

years

A single character string representing the NHANES cycle to select, choose from: "0506", "0708", "0910", "1112", "1314", "1516", or "1718".

component

A single character string with the HEI component to score and plot. Options include "total score", "total fruit", "whole fruits", "total vegetables", "greens and beans", "whole grains", "total dairy", "total protein", "seafood and plant proteins", "fatty acids", "refined grains", "sodium", "added sugars", and "saturated fat".

demo

A single character string with the demographic grouping by which the data should be scored or NULL. If method = "simple", choose NULL as the demo. Otherwise, choose from "sex", "race", "age", or "income".

sex

A vector of the sexes in the desired subpopulation. Provide a vector with the character strings "Female", "Male", or both.

race

A vector of races/ethnicities in the desired subpopulation. Provide a vector including any combination of the following character strings: "Asian", "White", "Black", "Other", "Mexican American", and "Other Hispanic".

age

A vector in the form c(min, max) with two integers specifying the desired age range to analyze. Both integers should either be ones (to represent the toddler age group including ages 12-23 months) or 2 and above.

income

A vector of family income brackets in the desired subpopulation. Provide a vector including any combination of the following character strings: "[0, 5000)","[5000, 10000)","[10000, 15000)","[15000, 20000)","[20000, 25000)","[25000, 35000)", "[35000, 45000)","[45000, 55000)","[55000, 65000)","[65000, 75000)","[75000, 100000)", "75000+",">100000", ">20000","<20000","Refused","Don't know", "NA".

Value

A base R plot or a ggplot object with the specified plot

Examples

# Plot the Total Dairy component score from the 2005-06 NHANES data using the
# "simple" method.

dairy_plot <- plotScore(graph = "histogram",
                        method = "simple",
                        years = "0506",
                        component = "total dairy")
dairy_plot

# Create a radar plot to display the total HEI score by race/ethnicity using
# the mean ratio method for subjects that are male, more than 50 years old,
# with a family income in the range [65000, 75000) for the 2015-16 NHANES
# cycle.
radar_example_plot <- plotScore(graph = "radar",
                    method = "mean ratio",
                    years = "1516",
                    component = "total score",
                    demo = "race",
                    sex = "Male",
                    age = c(50, 150),
                    income = "[65000, 75000)")
radar_example_plot


Launch Shiny app to visualize Healthy Eating Index (HEI) scores

Description

This function launches a Shiny application that allows users to visualize HEI scores calculated from National Health and Nutrition Examination Survey (NHANES) 24-hour dietary recall data.

Usage

runShinyApp()

Value

No return value, launches interactive Shiny app

Shiny App Tab Information

Tab 1 - Variable Information: The Variable Information tab provides additional information on dietary components and constituents.

Tab 2 - Demographics: The Demographics tab displays a bar chart that illustrates the distribution of the NHANES sample across categories including sex, race, age, and income. The chart is weighted to ensure the distribution is aligned with the demographics of the entire United States.

Side Panel Options

Tab 3 - Recalls: The Recalls tab displays a histogram of the raw consumption of the selected food group, weighted to make the distribution representative of the United States.

Side Panel Options

Below Plot Options

Tab 4 - Scoring: The Scoring tab visualizes HEI scores from NHANES data. The graphs are weighted to make the distributions representative of the United States.

Side Panel Options

Below Plot Options

Examples


runShinyApp()


Calculate Healthy Eating Index (HEI) scores from NHANES data

Description

This function calculates HEI component or total scores using the inputted scoring method. The user can subset the data to only include subjects in specific demographic groups

Usage

score(
  method,
  years,
  component,
  demo = NULL,
  sex = c("Female", "Male"),
  race = c("Asian", "White", "Black", "Other", "Mexican American", "Other Hispanic"),
  age = c(2, 100),
  income = c("[0, 5000)", "[5000, 10000)", "[10000, 15000)", "[15000, 20000)",
    "[20000, 25000)", "[25000, 35000)", "[35000, 45000)", "[45000, 55000)",
    "[55000, 65000)", "[65000, 75000)", "[75000, 100000)", "75000+", ">100000", ">20000",
    "<20000", "Refused", "Don't know", "NA")
)

Arguments

method

A single character string with the HEI scoring method to use. Choose from "simple", "pop ratio", or "mean ratio".

years

A single character string representing the NHANES cycle to select, choose from: "0506", "0708", "0910", "1112", "1314", "1516", or "1718".

component

A single character string with the HEI component to score and plot. Options include "total score", "total fruit", "whole fruits", "total vegetables", "greens and beans", "whole grains", "total dairy", "total protein", "seafood and plant proteins", "fatty acids", "refined grains", "sodium", "added sugars", and "saturated fat".

demo

A single character string with the demographic grouping by which the data should be scored or NULL. If method = "simple", choose NULL as the demo. Otherwise, choose from "sex", "race", "age", or "income".

sex

A vector of the sexes in the desired subpopulation. Provide a vector with the character strings "Female", "Male", or both.

race

A vector of races/ethnicities in the desired subpopulation. Provide a vector including any combination of the following character strings: "Asian", "White", "Black", "Other", "Mexican American", and "Other Hispanic".

age

A vector in the form c(min, max) with two integers specifying the desired age range to analyze. Both integers should either be ones (to represent the toddler age group including ages 12-23 months) or 2 and above.

income

A vector of family income brackets in the desired subpopulation. Provide a vector including any combination of the following character strings: "[0, 5000)","[5000, 10000)","[10000, 15000)","[15000, 20000)","[20000, 25000)","[25000, 35000)", "[35000, 45000)","[45000, 55000)","[55000, 65000)","[65000, 75000)","[75000, 100000)", "75000+",">100000", ">20000","<20000","Refused","Don't know", "NA".

Value

A tibble with HEI scores for the selected component for each individual (when method = "simple") or by demographic grouping specified in demo.

Examples

# Calculate the Total Fruit component score from the 2017-18 NHANES data
# using the 'simple' method.
score(method = "simple",
                    years = "1718",
                    component = "Total Fruit",
                    demo = NULL)

# Calculate the total HEI score by sex using the population ratio method for
# White and Black individuals between ages 5 and 10 with a family income
# between 5000abd 15000 in the 2011-12 NHANES cycle.
score(method = "pop ratio",
                    years = "1112",
                    component = "total score",
                    demo = "sex",
                    race = c("White", "Black"),
                    age = c(5,10),
                    income = c("[5000, 10000)", "[10000, 15000)"))


Retrieve a tibble with WWEIA NHANES data

Description

This function retrieves a tibble containing the raw 24-hour recall data from the What We Eat in America (WWEIA), National Health and Nutrition Examination Survey (NHANES) converted to the U.S. Department of Agriculture (USDA) Food Patterns components from the NHANES cycle selected.

Usage

selectDataset(years)

Arguments

years

A single character string representing the NHANES cycle to select, choose from: "0506", "0708", "0910", "1112", "1314", "1516", or "1718".

Value

A tibble containing Food Patterns component consumption, sample weights, and demographic information for each subject in the selected NHANES cycle.

Examples

# Retrieve WWEIA NHANES data for the 2015-2016 cycle
FPED_1516 <- selectDataset(years = "1516")
FPED_1516

# Retrieve WWEIA NHANES data for the years 2017-2018
FPED_1718 <- selectDataset(years = "1718")
FPED_1718