Calculates Healthy Eating Index (HEI) scores for National Health and Nutrition Examination Survey (NHANES) data sets to facilitate analysis of demographic and dietary differences.


The goal of hei is to calculate Healthy Eating Index (HEI) scores from National Health and Nutrition Examination Survey (NHANES) data for use in dietary analyses. The HEI is a dietary metric designed by the USDA and NCI to gauge adherence to the US Dietary Guidelines.


hei is available on CRAN, and can be installed as follows:


To install the development version hosted on this repository, use the devtools package and the following:

# install.packages("devtools")

Getting Started


The hei package contains one key function:

hei() takes as its arguments three data sets: an FPED data set, a NHANES dietary data set, and an NHANES demographic data set, returning a HEI score for each individual in the NHANES study being analyzed.

hei also includes get_fped() get_diet() and get_demo() for retrieving data from the Food Patterns Equivalents Database (FPED) and the NHANES dietary and demographic databases, respectively. The FPED data sets (in the public domain) retrieved by get_fped() are built into the package and have been converted to .csv files from the SAS data format in which they were originally published by their creators. get_diet() and get_demo() require the R package nhanesA which is employed to retrieve NHANES data sets directly from the web.

hei is intended as a tool to aid in the analysis of NHANES data. It is important to be familiar with NHANES and its complex survey design as well as the FPED, which is derived from NHANES, before beginning any analyses involving the HEI.


hei is licensed under the GNU General Public License Version 3. Questions, feature requests and bug reports are welcome via the issue queue. The maintainer will review pull requests and incorporate contributions at his discretion.


. hei: Calculate Healthy Eating Index (HEI) Scores. Journal of Open Source Software, 2017.

PDF Project doi.org/10.21105/joss.00417