knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  progress = FALSE,
  error = FALSE, 
  message = FALSE
)

options(digits = 2)
  1. The first step is to open up a session with the WoS API. auth() will authenticate your credentials with the the API's server and return a session ID (SID).
library(wosr)
sid <- auth(username = "your_username", password = "your_password")
library(wosr)
sid <- auth()
  1. Now we can query the Web of Science to see how many records match our query string.
# Find all publications that contain "animal welfare" in their titles (TI tag)
# and have the words "dog" and "welfare" somewhere in their titles, abstracts, or
# list of keywords (TS tag).
query <- 'TI = ("animal welfare") AND TS = (dog welfare)'
query_wos(query, sid = sid)
  1. Pull the data.
data <- pull_wos(query, sid = sid)
data
  1. pull_wos() returns a series of data frames that are like tables in a relational database. You an link these data frames together as needed, to answer whatever questions you have. For example:

  2. What are the top 5 journal subject categories (JSCs) in this set of publications and which publications are classified into these JSCs?

library(dplyr)

top_jscs <- 
  data$jsc %>% 
    group_by(jsc) %>% 
    count() %>% 
    arrange(desc(n)) %>% 
    head()

top_jscs
data$jsc %>% 
  inner_join(top_jscs, by = "jsc") %>% 
  inner_join(data$publication, by = "ut") %>% 
  select(title) %>% 
  distinct() %>% 
  head()
cat_pubs <- 
  data$publication %>% 
    filter(grepl("\\bcat\\b", abstract, ignore.case = TRUE)) %>% 
    select(ut)

cat_pubs
cat_authors <- 
  data$author %>% 
    semi_join(cat_pubs, by = "ut") %>% 
    select(ut, author_no, display_name)

cat_authors
cat_authors %>% 
  inner_join(data$author_address, by = c("ut", "author_no")) %>% 
  inner_join(data$address, by = c("ut", "addr_no")) %>% 
  select(ut, author_no, display_name, org)
data$grant %>% 
  inner_join(data$publication, by = "ut") %>% 
  select(grant_agency, ut, tot_cites) %>% 
  distinct() %>% 
  arrange(desc(tot_cites)) %>% 
  head()
  1. Download more detailed citation data (from the InCites API) for the top-cited publications
top_100_pubs <- 
  data$publication %>% 
    arrange(desc(tot_cites)) %>% 
    slice(1:100) %>% 
    .$ut

head(pull_incites(top_100_pubs, key = "your_incites_key"))
top_100_pubs <- 
  data$publication %>% 
    arrange(desc(tot_cites)) %>% 
    slice(1:100) %>% 
    .$ut

head(pull_incites(top_100_pubs))


jessicabeyer/wosr documentation built on May 31, 2019, 10:03 a.m.