This repository has been archived by the owner on Dec 30, 2023. It is now read-only.
/
README.Rmd
163 lines (100 loc) · 4.39 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
cache = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# lens2r
<!-- badges: start -->
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![R CMD Check via {tic}](https://github.com/sbalci/lens2r/workflows/R%20CMD%20Check%20via%20{tic}/badge.svg?branch=master)](https://github.com/sbalci/lens2r/actions)
[![Travis build status](https://travis-ci.com/sbalci/lens2r.svg?branch=master)](https://travis-ci.com/sbalci/lens2r)
<!-- badges: end -->
The goal of lens2r is to get Lens.org scholar data into R environment.
You need Lens.org scholar API token to access data, you can [get one here](https://www.lens.org/lens/user/subscriptions#scholar).
> Scholarly Search and Analysis
Lens serves over 200 million scholarly records, compiled and harmonised from Microsoft Academic, PubMed and Crossref, enhanced with UnPaywall open access information, CORE full text and links to ORCID. The full scholarly citation graph is provided for the first time as an open public resource.
🔬🔬🔬🔬 UNDER CONSTRUCTION 🛠⛔️⚠️🔩
## Installation
<!-- You can install the released version of lens2r from [CRAN](https://CRAN.R-project.org) with: -->
<!-- ``` r -->
<!-- install.packages("lens2r") -->
<!-- ``` -->
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("sbalci/lens2r")
```
## Examples
```{r example}
library(lens2r)
request <- '{
"query": {
"match_phrase": {
"author.affiliation.name": "Harvard University"
}
},
"size": 1,
"sort": [{
"year_published": "desc"
}]
}'
data <- lens2r::get_scholarly_data(query = request)
output_content <- httr::content(data, "text")
output_flatten <- jsonlite::fromJSON(output_content, flatten = TRUE)
output_flatten_data <- output_flatten$data
output_flatten_data
output_flatten <- as.data.frame(output_flatten)
output_flatten
```
## Similar Works
### lensr
A package to access patent data from the Lens Patent Database
Deprecated
https://github.com/poldham/lensr
### covidlens
https://github.com/poldham/covidlens
Scientific and Patent Literature on Covid-19 Corona Virus from the Lens for R https://poldham.github.io/covidlens/
### R codes in Lens.org API documentation
https://docs.api.lens.org/samples.html#r
These are the basic codes this package uses
```r
require(httr)
getScholarlyData <- function(token, query){
url <- 'https://api.lens.org/scholarly/search'
headers <- c('Authorization' = token, 'Content-Type' = 'application/json')
httr::POST(url = url, add_headers(.headers=headers), body = query)
}
token <- 'your-access-token'
request <- '{
"query": {
"match_phrase": {
"author.affiliation.name": "Harvard University"
}
},
"size": 1,
"sort": [{
"year_published": "desc"
}]
}'
data <- getScholarlyData(token, request)
content(data, "text")
```
---
<a class="twitter-follow-button" data-show-count="false" href="https://twitter.com/serdarbalci">Follow @serdarbalci</a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<a class="bmc-button" target="_blank" href="https://www.buymeacoffee.com/bS0teIs"><img src="https://cdn.buymeacoffee.com/buttons/bmc-new-btn-logo.svg" alt="Buy me a coffee"><span style="margin-left:15px;font-size:28px !important;">Buy me a coffee</span></a>
https://paypal.me/serdarbalci
![GitHub followers](https://img.shields.io/github/followers/sbalci?style=social)
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/sbalci)
---
## Development Status
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![R CMD Check via {tic}](https://github.com/sbalci/lens2r/workflows/R%20CMD%20Check%20via%20{tic}/badge.svg?branch=master)](https://github.com/sbalci/lens2r/actions)
[![Travis build status](https://travis-ci.com/sbalci/lens2r.svg?branch=master)](https://travis-ci.com/sbalci/lens2r)