knitr::opts_chunk$set(
  collapse = TRUE,
  cache = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

lens2r

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

R CMD Check via {tic} Travis build status

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.

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 development version from GitHub with:

# install.packages("devtools")
devtools::install_github("sbalci/lens2r")

Examples

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

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")


Buy me a coffeeBuy me a coffee

https://paypal.me/serdarbalci

GitHub followers
Say Thanks!


Development Status

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. R CMD Check via {tic} Travis build status



sbalci/lens2r documentation built on Jan. 18, 2021, 9:12 a.m.