Healthy Eating Index (HEI) scoring is not the simplest of calculations. But this package simply does it! Function hei() will compute HEI-2015 total and component scores using data from ‘ASA24’ (2016 version and subsequent versions). It implements the ‘simple HEI scoring algorithm’ as described at https://epi.grants.cancer.gov/hei/hei-methods-and-calculations.html. The ‘ASA24’ system is described at https://epi.grants.cancer.gov/asa24. HEI-2015 is described by Krebs-Smith et al. (2018) doi:10.1016/j.jand.2018.05.021.
You can install the released version of heir from CRAN with:
install.packages("heir")
And the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("AdamSadowski/heir")
Adding HEI columns to the end of a data frame via hei()
:
- Example data:
library(heir)
asa.df <- read.csv("./tests/testthat/asa_example_df.csv")
asa.df
#> X KCAL PROT TFAT CARB MOIS ALC CAFF THEO
#> 1 1 2063.981 78.03666 54.31533 328.5011 1509.486 0.000000 0.0000 0.0000
#> 2 2 1854.402 65.56360 56.62150 285.7208 1919.474 0.070112 2.6400 58.0800
#> 3 3 2500.603 96.19699 106.87751 299.6768 4352.941 0.000000 550.5337 149.9405
#> 4 4 1262.083 66.19420 52.98334 134.8168 2293.721 0.000000 0.0000 0.0000
#> 5 5 2223.039 103.66338 116.36062 198.7209 3348.943 0.000000 0.0000 1.0200
#> SUGR FIBE CALC IRON MAGN PHOS POTA SODI
#> 1 152.26761 26.57304 1266.9297 19.70547 356.2461 1491.284 3415.131 1831.419
#> 2 149.91463 22.03899 1633.3620 13.46108 324.3545 1555.786 2554.483 2085.237
#> 3 122.64686 30.73577 1182.1514 18.97396 433.7244 1783.541 3955.938 4755.138
#> 4 41.54655 19.25239 828.0764 10.11606 316.8518 1168.648 2068.882 3487.644
#> 5 46.55652 19.88774 840.0874 13.81818 378.6486 1588.656 3621.731 5126.402
#> ZINC COPP SELE VC VB1 VB2 NIAC VB6
#> 1 8.113932 1.194401 104.40353 239.69555 2.461698 2.335401 26.49975 2.687785
#> 2 9.505643 1.229695 98.00226 144.10858 1.076095 1.919909 10.26123 1.204583
#> 3 15.168911 1.759828 115.97227 90.01310 2.222864 3.075095 24.96578 1.804351
#> 4 10.239745 1.172207 72.21521 43.34367 1.057913 1.307072 11.80394 0.732030
#> 5 11.286614 1.669456 161.57301 114.61277 1.655926 2.145908 32.45657 2.783861
#> FOLA FA FF FDFE VB12 VARA RET BCAR
#> 1 433.9756 192.33870 239.2968 565.9877 3.561177 573.1471 453.1330 687.9291
#> 2 205.1816 91.69348 113.4881 269.1750 3.087226 973.7674 527.6379 4602.7896
#> 3 484.1433 182.93320 301.2100 612.1966 4.873569 651.8839 477.9677 1926.4447
#> 4 171.1453 33.87557 137.2697 194.8583 2.476689 297.8739 144.6969 1532.0500
#> 5 397.9941 78.12615 319.8680 452.6263 6.878937 808.9045 355.8959 5325.9794
#> ACAR CRYP LYCO LZ ATOC VK CHOLE SFAT
#> 1 125.8350 323.94000 1582.395 853.0262 13.746660 34.68600 150.0615 20.26609
#> 2 1145.7875 492.23500 25923.320 556.9525 4.024029 58.71637 137.6478 26.33512
#> 3 80.0600 264.24900 7334.250 3103.7295 6.944870 154.97784 282.7756 38.39328
#> 4 118.9950 510.08398 4889.500 2367.2380 9.386004 107.74067 132.8605 18.50102
#> 5 174.1075 31.21802 3186.258 8416.0016 12.423412 439.40424 444.6906 39.74848
#> S040 S060 S080 S100 S120 S140 S160 S180
#> 1 0.562115 0.556938 0.571536 0.594404 0.865582 2.375159 10.288684 4.279972
#> 2 1.113462 0.704074 0.443949 1.021806 1.214015 3.731528 11.999701 5.233475
#> 3 0.949727 0.562388 0.353749 0.786941 0.786475 3.699511 19.684468 10.080343
#> 4 0.532415 0.279649 0.183437 0.389371 0.417883 2.051287 9.821589 4.135317
#> 5 0.746311 0.425354 0.310943 0.789562 0.999461 3.606531 21.834829 9.982028
#> MFAT M161 M181 M201 M221 PFAT P182 P183
#> 1 13.97870 0.166896 13.75067 0.300954 0.004678 13.052255 11.202188 1.758623
#> 2 16.23567 0.730279 14.98820 0.082275 0.003060 8.099306 7.048572 0.951360
#> 3 36.40398 1.527493 28.32226 0.219828 0.016808 22.620997 19.439957 2.944922
#> 4 20.99047 0.894717 15.87815 0.071875 0.002972 8.947344 8.101312 0.704339
#> 5 41.92797 2.491959 38.66248 0.414214 0.014417 21.389261 18.324752 2.690621
#> P184 P204 P205 P225 P226 VITD CHOLN VITE_ADD
#> 1 0.000977 0.051753 0.003590 0.006205 0.004137 9.818487 267.4769 0
#> 2 0.024268 0.038445 0.005524 0.008128 0.000464 5.673768 188.7396 0
#> 3 0.004209 0.096213 0.004809 0.005159 0.011548 5.461709 390.7249 0
#> 4 0.000394 0.066943 0.000118 0.000000 0.000230 0.372319 203.0636 0
#> 5 0.002372 0.189559 0.007417 0.015081 0.041665 3.404555 442.3806 0
#> B12_ADD F_TOTAL F_CITMLB F_OTHER F_JUICE V_TOTAL V_DRKGR V_REDOR_TOTAL
#> 1 0 4.916160 1.414800 2.446800 1.05456 0.362850 0.000000 0.362850
#> 2 0 5.854325 4.084575 1.025750 0.74400 1.399325 0.000000 0.256000
#> 3 0 2.508800 0.000000 2.446800 0.06200 2.021475 0.000000 0.419100
#> 4 0 0.519996 0.501797 0.018198 0.00000 1.101900 0.214500 0.279400
#> 5 0 0.676700 0.000000 0.676700 0.00000 4.971475 0.999375 0.730125
#> V_REDOR_TOMATO V_REDOR_OTHER V_STARCHY_TOTAL V_STARCHY_POTATO V_STARCHY_OTHER
#> 1 0.362850 0.000 0.000 0.000 0.000
#> 2 0.000000 0.256 0.000 0.000 0.000
#> 3 0.419100 0.000 0.504 0.000 0.504
#> 4 0.279400 0.000 0.000 0.000 0.000
#> 5 0.730125 0.000 0.858 0.858 0.000
#> V_OTHER V_LEGUMES G_TOTAL G_WHOLE G_REFINED PF_TOTAL PF_MPS_TOTAL PF_MEAT
#> 1 0.000000 0.0000 11.334000 4.647000 6.687000 2.617500 2.61750 0.0000
#> 2 1.143325 0.0000 6.270600 3.418000 2.852600 0.015000 0.00000 0.0000
#> 3 1.098375 0.5334 10.277100 0.000000 10.277100 4.263500 3.80670 2.3241
#> 4 0.608000 0.3556 4.624934 2.828111 1.796824 5.174299 3.66740 1.5494
#> 5 2.383975 0.0000 6.799800 2.805950 3.993850 8.314851 7.41575 0.0000
#> PF_CUREDMEAT PF_ORGAN PF_POULT PF_SEAFD_HI PF_SEAFD_LOW PF_EGGS PF_SOY
#> 1 0.00000 0 2.6175 0 0 0.000000 0
#> 2 0.00000 0 0.0000 0 0 0.015000 0
#> 3 1.48260 0 0.0000 0 0 0.456800 0
#> 4 2.11800 0 0.0000 0 0 0.006899 0
#> 5 4.41435 0 3.0014 0 0 0.899101 0
#> PF_NUTSDS PF_LEGUMES D_TOTAL D_MILK D_YOGURT D_CHEESE OILS SOLID_FATS
#> 1 0.0 0.0000 3.036400 3.036400 0.00 0.000000 8.176702 30.25190
#> 2 0.0 0.0000 4.401234 1.619100 0.33 2.452134 9.374000 34.12409
#> 3 0.0 2.1336 2.513563 1.514225 0.00 0.999338 26.017563 57.60759
#> 4 1.5 1.4224 1.432985 0.766760 0.00 0.666225 14.382506 22.48894
#> 5 0.0 0.0000 1.338342 0.079600 0.00 1.231142 51.914236 68.63530
#> ADD_SUGARS A_DRINKS
#> 1 3.545800 0
#> 2 12.648800 0
#> 3 13.363900 0
#> 4 3.538002 0
#> 5 5.090900 0
hei()
creates HEI variables for each row. It accepts a data frame and returns it with these added variables.
df <- hei(asa.df)
# grep just to show X and HEI variables
df[, grep("X|HEI", names(df))]
#> X HEI2015_C1_TOTALVEG HEI2015_C2_GREEN_AND_BEAN HEI2015_C3_TOTALFRUIT
#> 1 1 0.7990955 0 5.000000
#> 2 2 3.4299832 0 5.000000
#> 3 3 4.6441069 5 5.000000
#> 4 4 5.0000000 5 2.575089
#> 5 5 5.0000000 5 1.902520
#> HEI2015_C4_WHOLEFRUIT HEI2015_C5_WHOLEGRAIN HEI2015_C6_TOTALDAIRY
#> 1 5.00000 10.000000 10.000000
#> 2 5.00000 10.000000 10.000000
#> 3 5.00000 0.000000 7.732175
#> 4 5.00000 10.000000 8.733946
#> 5 3.80504 8.414759 4.631021
#> HEI2015_C7_TOTPROT HEI2015_C8_SEAPLANT_PROT HEI2015_C9_FATTYACID
#> 1 2.53636008 0 1.029250
#> 2 0.01617772 0 0.000000
#> 3 5.00000000 5 2.595213
#> 4 5.00000000 5 3.216700
#> 5 5.00000000 0 3.022670
#> HEI2015_C10_SODIUM HEI2015_C11_REFINEDGRAIN HEI2015_C12_SFAT
#> 1 10.000000 4.2405808 8.953704
#> 2 9.728007 10.0000000 4.023419
#> 3 1.093372 0.7606059 2.727190
#> 4 0.000000 10.0000000 3.508490
#> 5 0.000000 10.0000000 0.000000
#> HEI2015_C13_ADDSUG HEI2015_TOTAL_SCORE
#> 1 10.000000 67.55899
#> 2 7.736649 64.93424
#> 3 8.948291 53.50095
#> 4 10.000000 73.03422
#> 5 10.000000 56.77601