Description Usage Arguments Value Examples
Provides a plain text option to search the database.
1 2 3 |
api_key |
An API key as obtained from the USDA NDB. |
result_type |
The nature of the return result. Supports one of "xml" and "json" |
search_term |
A plain text string of the desired search term. |
data_source |
A string. One of Branded Food Products and Standard Release. |
food_group |
A string. A specific food_group. See examples below. |
sort_by |
One of 'r' for relevance and 'n' for name that decides the nature of sorting for the return items. |
max_rows |
The maximum number of rows to return. |
offset |
Determines the starting point for "indexing". Defaults to 0. |
A processed JSON result or xml result as may be requested.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
#set_apikey("key here if not set for the session")
#sorted by relevance
db_search(result_type = "json",search_term = "Acerola",
sort_by = "r")
# sorted by name
db_search(result_type = "json",search_term = "Acerola",
sort_by = "n")
# return xml
res<-db_search(result_type = "xml",search_term = "Acerola",
sort_by = "r")
#process xml
pretty_xml(res, tag="name")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.