get_nutrients: USDA Nutrient Database Information Retrieval.

Description Usage Arguments Value Source References Examples

Description

A simple function to access and retrieve nutrient data from the USDA nutrient data base.

Usage

1
2
3
get_nutrients(result_type = "json", nutrients = NULL, api_key = NULL,
  ndbno = NULL, subset = 0, offset = 25, max_rows = 50,
  food_group = NULL)

Arguments

result_type

A string. One of json or xml depending on the type of format required.

nutrients

A string or vector of strings. A nutrient id as provided on the nutrient data base website.

api_key

A string. A unique api_key obtained after signingup at [NDB](https://ndb.nal.usda.gov/ndb/doc/index#.) If this is not set with set_apikey, then the user can manually set it here.

ndbno

A string. A unique ndb number for a specific food of interest. Use this if nutrients is set to 'NULL'.

subset

Numeric. Defaults to 0 for all food types. 1 to return common food types.

offset

Where should offsetting begin? Defaults to 25. Lower values mean more results.

max_rows

Numeric. Maximum number of rows to return. Defaults to 50.

food_group

String. Return results for only a certain food group.

Value

A list of length two. The first list element returns unprocessed data if JSON is requested while the second is a data.frame object from JSON data. An XML file is returned if xml is requested.

Source

https://ndb.nal.usda.gov/ndb/doc/apilist/API-NUTRIENT-REPORT.md

References

U.S. Department of Agriculture, Agricultural Research Service. 20xx. USDA National Nutrient Database for Standard Reference, Release . Nutrient Data Laboratory Home Page, http://www.ars.usda.gov/nutrientdata

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
get_nutrients(result_type = "json", nutrients = "204",
food_group = "0500",
max_rows = 50, 
subset = 1)
# Use xml
get_nutrients(nutrients=c("204","205"),
result_type="xml",
offset = 0,
max_rows = 40,
ndbno = "01009")

# Multiple food groups
get_nutrients(nutrients=c("204","205"),
result_type="json",
offset = 25,
max_rows = 50,
food_group = c("0500","0100"))

## End(Not run)

Nelson-Gon/usdandbr documentation built on Jan. 22, 2020, 4:07 a.m.