-
Notifications
You must be signed in to change notification settings - Fork 16
/
README.Rmd
96 lines (69 loc) · 4.1 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
R Package to interface with Elsevier and Scopus APIs
<!-- ![Sticker](sticker.png) -->
<img src="sticker.png" width="100">
<!-- badges: start -->
[![Travis-CI Build Status](https://travis-ci.org/muschellij2/rscopus.svg?branch=master)](https://travis-ci.org/muschellij2/rscopus)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/muschellij2/rscopus?branch=master&svg=true)](https://ci.appveyor.com/project/muschellij2/rscopus)
[![CRAN status](https://www.r-pkg.org/badges/version/rscopus)](https://CRAN.R-project.org/package=rscopus)
[![](https://cranlogs.r-pkg.org/badges/rscopus)](https://cran.rstudio.com/web/packages/rscopus/index.html)
[![R-CMD-check](https://github.com/muschellij2/rscopus/workflows/R-CMD-check/badge.svg)](https://github.com/muschellij2/rscopus/actions)
<!-- badges: end -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# rscopus
The goal of rscopus is to provide an R Scopus Database 'API' Interface.
## Installation
You can install `rscopus` from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("muschellij2/rscopus")
```
## Steps to get API key
In order to use this package, you need an API key from https://dev.elsevier.com/sc_apis.html. You should login from your institution and go to Create API Key. You need to provide a website URL and a label, but the website can be your personal website, and agree to the terms of service.
1. Go to https://dev.elsevier.com/user/login. Login or create a free account.
2. Click "Create API Key". Put in a label, such as `rscopus key`. Add a website. http://example.com is fine if you do not have a site.
3. **Read** and agree to the TOS if you do indeed agree.
4. Add `Elsevier_API = "API KEY GOES HERE"` to `~/.Renviron` file, or add `export Elsevier_API=API KEY GOES HERE` to your `~/.bash_profile`.
Alternatively, you you can either set the API key using `rscopus::set_api_key` or by `options("elsevier_api_key" = api_key)`. You can access the API key using `rscopus::get_api_key`.
You should be able to test out the API key using the [interactive Scopus APIs](https://dev.elsevier.com/scopus.html).
### A note about API keys and IP addresses
The API Key is bound to a set of IP addresses, usually bound to your institution. Therefore, if you are using this for a Shiny application, you must host the Shiny application from your institution servers in some way. Also, you cannot access the Scopus API with this key if you are offsite and must VPN into the server or use a computing cluster with an institution IP.
See https://dev.elsevier.com/tecdoc_api_authentication.html
## Example
This is a basic example which shows you how to solve a common problem:
```{r example, eval = TRUE, message=FALSE}
library(rscopus)
library(dplyr)
if (rscopus::is_elsevier_authorized()) {
res = author_df(last_name = "Muschelli", first_name = "John", verbose = FALSE, general = FALSE)
names(res)
head(res[, c("title", "journal", "description")])
unique(res$au_id)
unique(as.character(res$affilname_1))
all_dat = author_data(last_name = "Muschelli",
first_name = "John", verbose = FALSE, general = TRUE)
res2 = all_dat$df
res2 = res2 %>%
rename(journal = `prism:publicationName`,
title = `dc:title`,
description = `dc:description`)
head(res[, c("title", "journal", "description")])
}
```
## Using an Institution Token
As per https://dev.elsevier.com/tecdoc_api_authentication.html: "Using a proprietary token (an "Institutional Token") created for you by our integration support team", so you need to contact Scopus to get one. If you have one and it's located in an object called `token`, you should be able to use it as:
```{r, eval = FALSE}
# token is from Scopus dev
hdr = inst_token_header(token)
res = author_df(last_name = "Muschelli", first_name = "John", verbose = FALSE, general = FALSE, headers = hdr)
```
but I have not tried it extensively.