## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

## ----setup--------------------------------------------------------------------
library(scopusflow)

## -----------------------------------------------------------------------------
scopus_field_tags()

## -----------------------------------------------------------------------------
scopus_query("CRISPR", .field = "TITLE-ABS-KEY")              # molecular biology
scopus_query("gravitational waves", .field = "TITLE-ABS-KEY") # physics
scopus_query("microplastics", .field = "TITLE-ABS-KEY")       # environmental science
scopus_query("blockchain", .field = "TITLE-ABS-KEY")          # computer science
scopus_query("digital humanities", .field = "AUTHKEY")        # humanities

## -----------------------------------------------------------------------------
# Two concepts that must co-occur (materials science).
scopus_query("perovskite", "solar cell", .field = "TITLE-ABS-KEY")

# Spelling variants, either of which will do (economics).
scopus_query("behavioral economics", "behavioural economics", .op = "OR")

# A family of related tools (molecular biology).
scopus_query("CRISPR", "Cas9", "Cas12", .op = "OR")

## -----------------------------------------------------------------------------
q <- scopus_query("gut microbiome", "immunology", .field = "TITLE-ABS-KEY")
q
plan <- scopus_plan(q, years = 2015:2022, partition = "year")
plan

## ----eval = FALSE-------------------------------------------------------------
# scopus_count(q, years = 2015:2022)
# records <- scopus_fetch_plan(plan)

## -----------------------------------------------------------------------------
scopus_query("Max Planck", .field = "AFFILORG")

## -----------------------------------------------------------------------------
tryCatch(
  scopus_query("graphene", ""),
  scopus_error_bad_input = function(e) conditionMessage(e)
)

