View source: R/Record_search.R
clean_date_filter_arg | R Documentation |
Take a period definition and transform it into a specific format passed
through the cases
argument.
clean_date_filter_arg( year_query, cases, arg_in_query_test = NULL, query = NULL )
year_query |
A string identifying a search period (see Details). |
cases |
The search engine syntax specification into which convert the
year query It needs to be a list with the following items: gt (greater
than), ge (greater than or equal to), lt (lower than), le (lower than or
equal to), eq (equal to), range (range of years). Inside the specification,
the year in the query can be retrieved with the |
arg_in_query_test |
A search engine syntax tag that identifies a year
filter. Useful to define an already existing year filter in the query. If
|
query |
The search query. Needed to test if a year filter is already
present. If |
The input period specified in year_query
must follow this format:
> Year
: greater than Year
.
>=
Year
: greater then or equal to Year
.
< Year
: lower
than Year
.
<= Year
: lower then or equal to
Year
.
Year
: equal to
Year
.
Year1-Year2
: range from Year1
to
Year2
.
The input is checked to evaluate if year_query
the format is clearly
invalid.
The formatted, search engine specific, period filter.
query <- "Test query" year_query <- "2010-2020" ## Example for Web Of Science year_query <- clean_date_filter_arg(year_query, cases = list( gt = "{year_piece + 1}-{year(today())}", ge = "{year_piece}-{year(today())}", eq = "{year_piece}-{year_piece}", le = "1985-{year_piece}", range = "{year_piece[1]}-{year_piece[2]}", lt = "1985-{year_piece - 1}" ), arg_in_query_test = "PY ?=", query = query ) ## Example for Pubmed year_query <- "2010-2020" year_query <- clean_date_filter_arg(year_query, cases = list( gt = "{year_piece + 1}[PDAT]:{year(today())}[PDAT]", ge = "{year_piece}[PDAT]:{year(today())}[PDAT]", eq = "{year_piece}[PDAT]:{year_piece}[PDAT]", le = "1000[PDAT]:{year_piece}[PDAT]", lt = "1000[PDAT]:{year_piece - 1}[PDAT]", range = "{year_piece[1]}[PDAT]:{year_piece[2]}[PDAT]" ), arg_in_query_test = "[PDAT]", query = query )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.