nutrient: Nutrient data table.

Description Usage Format Examples

Description

Nutrient values and information about the values, including expanded statistical information.

Usage

1

Format

A data frame with 632,894 observations and 18 variables:

food_id

Food identifier. Joins with food

nutr_id

Nutrient identifier. Joins with nutrient_def

value

Amount of nutrient in 100g.

num_points

Number of analyses used to compute value. If the number of data points is 0, the value was calculated or imputed.

se

Standard error of the mean. NA if cannot be calculated. The standard error is also not given if the number of data points is less than three

source_type_id

Code indicating type of data. Joins with source_type

deriv_id

Data derivation code. Joins with deriv

impute_id

Food identifier for the item used to calculate a missing value. Populated only for items added or updated starting with SR14.

fortified

Indicates a vitamin or mineral added for fortification or enrichment. This field is populated for ready-to-eat breakfast cereals and many brand-name hot cereals in food group 8.

num_studies

Number of studies.

min,max

Minimum & maximum value from studies

df

degrees of freedom

lwr,upr

Lower and upper 95% CI around mean

comments

Statistical comments

modified

Month value added or modified

cc

Confidence Code indicating data quality, based on evaluation of sample plan, sample handling, analytical method, analytical quality control, and number of samples analyzed. Not included in this release, but is planned for future releases.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
nutrient

# To find a name nutrient information for a specified food, you need to
# join food, nutrient and nutrient_def
if (require("dplyr") && require("tidyr")) {
  nutr_info <- food %>%
    select(food_id, food) %>%
    inner_join(nutrient %>% select(food_id, nutr_id, value)) %>%
    inner_join(nutrient_def %>% select(nutr_id, nutr_abbr))

 # Often easiest to understand if you spread the nutrient values out
 # in to columns. We'll do this for the 10 most prevalent nutrients
 top_nutr <- nutrient %>%
   group_by(nutr_id) %>%
   tally(sort = TRUE) %>%
   head(10)

 nutr_info %>%
   semi_join(top_nutr) %>%
   select(food_id, food, nutr_abbr, value) %>%
   spread(nutr_abbr, value)
}

hadley/usdanutrients documentation built on May 17, 2019, 1:31 p.m.