Using a loop to download data

Hello,

I have a large spreadsheet with company names and I would like to find out the number of CRISPR-related patents published by each company. There is a publicly available R code which allows users to perform a boolean search using key terms (such as CRISPR). Can you please help me add a loop which includes a search for each company name in my spreadsheet?

In plain English, I would like my code to perform a search for company1 AND (title: CRISPR OR abstract: CRISPR OR claim: CRISPR). Followed by the same search for company2 and so on.

Many thanks,
Nadya

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'
{
    "query": {
        "bool": {
            "must": [
                {
                    "bool": {
                        "should": [
                            {
                                "match" : {
                                    "title": "CRISPR"
                                }
                            },
                            {
                                "match" : {
                                    "abstract": "CRISPR"
                                }
                            },
                            {
                                "match" : {
                                    "claim": "CRISPR"
                                }
                            }
                        ]
                    }
                },
                {
                    "term" : {
                        "jurisdiction": "CN"
                    }
                
                },
                {
                    "range" : {
                        "date_published": {
                            "gte": "2010-09-01",
                            "lte": "2020-09-30"
                        }
                    }
                
                }
            ]
        }
    },
    "size" : 10,
    "include": ["lens_id", "biblio.publication_reference", "biblio.invention_title.text", "abstract.text", "claims.claims.claim_text"]
}
data <- getScholarlyData(token, request)
content(data, "text")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.