Description Usage Arguments Value Source References Examples
A simple function to access and retrieve nutrient data from the USDA nutrient data base.
1 2 3 |
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
|
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. |
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.
https://ndb.nal.usda.gov/ndb/doc/apilist/API-NUTRIENT-REPORT.md
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
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.