Description Usage Arguments Details Value References See Also Examples
A convenient wrapper function to obtain lists from the USDA nutrient databases. It queries the database for a list of foods, food groups or nutrients.
1 2 3 |
list_type |
A character(string). One of f,n,ns,nr,f, and g. See details below. |
sort_by |
A character(string). How would you like to sort the lists? One of n for name and id. id differs depending on the list type. |
api_key |
string. A valid api_key obtained from https://ndb.nal.usda.gov/ndb/doc/index# |
max_items |
integer. Maximum number of items to return. |
offset |
integer. Where should querying start? Defaults to 0. |
format |
string. What kind of output do you need? Supports "xml" and "json" |
return_request |
If format is set to json, this controls whether the initial request is returned to the user. Defaults to FALSE. |
For list_type d represents derived foods, f for food, n for all nutrients, ns speciality nutrients, nr for standard nutrients and g for food group. Details available at https://ndb.nal.usda.gov/ndb/doc/apilist/API-LIST.md
A list depending on the requested format type. For JSON, a list of length 2 if return request is requested. Otherwise a list of length 1 with a semi_processed JSON object. The return value for XML is an xml document.
https://ndb.nal.usda.gov/ndb/doc/apilist/API-LIST.md
get_nutrients
pretty_xml
get_nutrient_info
1 2 3 4 5 6 7 8 9 | ## Not run:
res <- get_list(
list_type = "ns",sort_by = "id",
max_items = 50,offset = 12,format = "xml")
res
usdar::pretty_xml(res,tag="name")
usdar::pretty_json(res)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.