View source: R/format_sort_term.R
format_sort_term | R Documentation |
sort
terms for openFDA API queriesThis function acts as a helper for constructing a sort term in the openFDA API.
format_sort_term(sort)
sort |
A single-length character vector of length 1. If unnamed, it will be assumed that you have already formatted your search string to work with the API. If named, the vector will be collapsed to include your field and sorting choice. |
A character vector of the S3 class <AsIS>
, with a formatted search
term which can be supplied to openFDA()
.
This function does not check that you're providing accurate field names or search terms. It is up to you to make sure you've provided correctly spelt fields and search terms.
format_search_term()
performs similar formatting for the search
component of an openFDA query.
I()
generates vectors with the <AsIs>
S3 class.
httr2::req_url()
documents why I()
is applied to the output of this
function.
# Provide a formatted search string and the function will do no formatting
format_sort_term("openfda.generic_name:asc")
# Provide a named vector and the function will format it for you
format_sort_term(c("openfda.generic_name" = "asc"))
# Errors will be thrown if you supply a bad input
try(format_sort_term("receivedate:no_order"))
try(format_sort_term(c("receivedate" = "ascending")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.