## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") # The plotting chunks below need ggplot2 (a suggested package); skip them # gracefully when it is not installed. has_ggplot2 <- requireNamespace("ggplot2", quietly = TRUE) ## ----setup-------------------------------------------------------------------- library(scopusflow) ## ----eval = FALSE------------------------------------------------------------- # cmp <- scopus_compare_topics( # reference_query = "deep learning", # comparison_terms = c("computer vision", "natural language processing", # "medical imaging", "drug discovery"), # years = 2013:2021, # field = "TITLE-ABS-KEY" # ) ## ----------------------------------------------------------------------------- years <- 2013:2021 ref_n <- round(seq(400, 1600, length.out = length(years))) mk <- function(from, to) round(seq(from, to, length.out = length(years))) counts <- list( "computer vision" = mk(140, 720), "natural language processing" = mk(90, 540), "medical imaging" = mk(15, 260), "drug discovery" = mk(8, 170) ) cmp <- tibble::tibble( query = "q", query_type = c(rep("reference", length(years)), rep("comparison", length(counts) * length(years))), abridged_query = c(rep("deep learning", length(years)), rep(names(counts), each = length(years))), year = rep(years, length(counts) + 1), n = c(ref_n, unlist(counts, use.names = FALSE)), reference_n = rep(ref_n, length(counts) + 1), comparison_percentage = 100 * c(ref_n, unlist(counts, use.names = FALSE)) / rep(ref_n, length(counts) + 1), average_comparison_percentage = c(rep(100, length(years)), rep(c(40, 33, 15, 9), each = length(years))) ) class(cmp) <- c("scopus_comparison", class(cmp)) cmp ## ----eval = has_ggplot2, fig.alt = "Four application areas' share of the deep-learning literature from 2013 to 2021, with shaded uncertainty bands", fig.width = 8, fig.height = 4.6---- plot_scopus_comparison(cmp) ## ----eval = has_ggplot2, fig.alt = "The same chart with the medical-imaging topic highlighted against the others in grey", fig.width = 8, fig.height = 4.6---- plot_scopus_comparison(cmp, highlight = "medical imaging") ## ----eval = has_ggplot2, fig.alt = "The comparison chart without record counts or bands", fig.width = 8, fig.height = 4.6---- plot_scopus_comparison(cmp, pub_count_in_legend = FALSE, interval = FALSE) ## ----------------------------------------------------------------------------- comp <- cmp[cmp$query_type == "comparison", ] unique(comp[, c("abridged_query", "average_comparison_percentage")])