Learn R Programming

rcrossref (version 0.5.2)

cr_works: Search CrossRef works (articles)

Description

Search CrossRef works (articles)

Usage

cr_works(dois = NULL, query = NULL, filter = NULL, offset = NULL, limit = NULL, sample = NULL, sort = NULL, order = NULL, facet = FALSE, cursor = NULL, cursor_max = 5000, .progress = "none", ...)
cr_works_(dois = NULL, query = NULL, filter = NULL, offset = NULL, limit = NULL, sample = NULL, sort = NULL, order = NULL, facet = FALSE, cursor = NULL, cursor_max = 5000, .progress = "none", parse = FALSE, ...)

Arguments

dois
Search by a single DOI or many DOIs.
query
Query terms
filter
Filter options. See details.
offset
Number of record to start at, from 1 to infinity.
limit
Number of results to return in the query. Not relavant when searching with specific dois. Default: 20. Max: 1000
sample
(integer) Number of random results to return. when you use the sample parameter, the rows and offset parameters are ignored. Ignored unless works=TRUE
sort
(character) Field to sort on, one of score, relevance, updated, deposited, indexed, or published.
order
(character) Sort order, one of 'asc' or 'desc'
facet
(logical) Include facet results. Default: FALSE
cursor
(character) Cursor character string to do deep paging. Default is None. Pass in '*' to start deep paging. Any combination of query, filters and facets may be used with deep paging cursors. While rows may be specified along with cursor, offset and sample cannot be used. See https://github.com/CrossRef/rest-api-doc/blob/master/rest_api.md#deep-paging-with-cursors
cursor_max
(integer) Max records to retrieve. Only used when cursor param used. Because deep paging can result in continuous requests until all are retrieved, use this parameter to set a maximum number of records. Of course, if there are less records found than this value, you will get only those found.
.progress
Show a plyr-style progress bar? Options are "none", "text", "tk", "win", and "time". See create_progress_bar for details of each. Only used when passing in multiple ids (e.g., multiple DOIs, DOI prefixes, etc.)
...
Named parameters passed on to GET
parse
(logical) Whether to output json FALSE or parse to list TRUE. Default: FALSE

Beware

The API will only work for CrossRef DOIs.

Functions

  • cr_works() - Does data request and parses to data.frame for easy downstream consumption
  • cr_works_() - Does data request, and gives back json (default) or lists, with no attempt to parse to data.frame's

References

https://github.com/CrossRef/rest-api-doc/blob/master/rest_api.md

Examples

Run this code
## Not run: 
# # Works funded by the NSF
# cr_works(query="NSF")
# 
# # Works that include renear but not ontologies
# cr_works(query="renear+-ontologies")
# 
# # Filter
# cr_works(query="global state", filter=c(has_orcid=TRUE), limit=3)
# # Filter by multiple fields
# cr_works(filter=c(has_orcid=TRUE, from_pub_date='2004-04-04'))
# # Only full text articles 
# cr_works(filter=c(has_full_text = TRUE))
# # has affilitation data
# cr_works(filter=c(has_affiliation = TRUE))
# 
# # Querying dois
# cr_works(dois='10.1063/1.3593378')
# cr_works('10.1371/journal.pone.0033693')
# cr_works(dois='10.1007/12080.1874-1746')
# cr_works(dois=c('10.1007/12080.1874-1746','10.1007/10452.1573-5125', '10.1111/(issn)1442-9993'))
# 
# # progress bar
# cr_works(dois=c('10.1007/12080.1874-1746','10.1007/10452.1573-5125'), .progress="text")
# 
# # Include facetting in results
# cr_works(query="NSF", facet=TRUE)
# ## Get facets only, by setting limit=0
# cr_works(query="NSF", facet=TRUE, limit=0)
# 
# # Sort results
# cr_works(query="ecology", sort='relevance', order="asc")
# res <- cr_works(query="ecology", sort='score', order="asc")
# res$data$score
# 
# # Get a random number of results
# cr_works(sample=1)
# cr_works(sample=10)
# 
# # You can pass in dot separated fields to filter on specific fields
# cr_works(filter=c(award.number='CBET-0756451', award.funder='10.13039/100000001'))
# 
# # Use the cursor for deep paging
# cr_works(query="NSF", cursor = "*", cursor_max = 300, limit = 100)
# cr_works(query="NSF", cursor = "*", cursor_max = 300, limit = 100, facet = TRUE)
# 
# # Low level function - does no parsing to data.frame, get json or a list
# cr_works_(query = "NSF")
# cr_works_(query = "NSF", parse=TRUE)
# cr_works_(query="NSF", cursor = "*", cursor_max = 300, limit = 100)
# cr_works_(query="NSF", cursor = "*", cursor_max = 300, limit = 100, parse=TRUE)
# ## End(Not run)

Run the code above in your browser using DataLab