knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
This is an extension to R operators +
, -
, |
, and @
to gain the ability to paste character vectors. This is useful when building queries for the PubMed database (see for example the rentrez package).
Get it from GitHub:
devtools::install_github("jchrom/qbuildr")
Avoiding the explicit call to paste
makes the code much cleaner:
library(qbuildr) query = "eeg" + "epilepsy" - "temporal" cat(query)
The @
operator can be used to add field specification:
query = "eeg" @ "TIAB" + "epilepsy" @ "MeSH" cat(query)
You can build nested queries using the g
function (for "group"). You can add field specification to multiple terms at once by providing a character vector:
query = "pain" @ "TIAB" + g("eeg" | "seeg", "MeSH") - g("mri" | "fmri" | "meg", "TIAB") cat(query)
Operators still work the usual way with numeric or logical inputs, but they may be slower, so beware:
# With redefined operators system.time(runif(10^7) + runif(10^7)) # With original operators detach("package:qbuildr", unload = TRUE) system.time(runif(10^7) + runif(10^7))
The advantages and pitfalls of this approach are discussed here and here.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.