Obtaining references

Owen Jones

2021-10-15

The following example illustrates how to find the full formatted citations for the publications used in COMADRE or COMPADRE. This can be useful to find further details of the matrices you may be using in your study, or to provide references for your data e.g. in supplementary information.

The code relies on the package rcrossref (https://github.com/ropensci/rcrossref) which queries CrossRef, a Digital Object Identifier (DOI) Registration Agency of the International DOI Foundation.

To install the rcrossref package:

install.packages("rcrossref")

We should then load the required packages like this:

library(Rcompadre)
library(rcrossref)

We aim to obtain the full reference and DOI for the matrices for a set of matrices. In this example we will use the example data available in the Rcompadre package.

data(Comadre)

Here we will create a subset of matrices containing data for species in the Ursidae family:

Comadre <- subset(Comadre, Family == "Ursidae")

In this case, our subset contains 3 matrices, and we can examine the source information for these by asking for the Authors, Journal, publication year (YearPublication) and DOI (DOI_ISBN) like this:

Comadre$Authors
#> [1] "Hunter; Caswell; Runge; Regehr; Amstrup; Stirling"
#> [2] "Carroll; Noss; Paquet; Schumaker"                 
#> [3] "Wielgus"
Comadre$YearPublication
#> [1] "2010" "2003" "2002"
Comadre$DOI_ISBN
#> [1] "10.1890/09-1641"               "10.1890/02-5195"              
#> [3] "10.1016/S0006-3207(01)00265-8"

We are now ready to obtain the full references for these data. The rcrossref package has a convenient function, cr_cn() which obtains citations in various formats from CrossRef based on the DOIs.

Thus, we can obtain the full references for this subset of the COMADRE database like this:

rcrossref::cr_cn(unique(Comadre$DOI_ISBN),format = "text",style = "apa")
#> Warning: Failure in resolving '10.1890/09-1641'. See error detail in results.
#> Warning: Failure in resolving '10.1890/02-5195'. See error detail in results.
#> Warning: Failure in resolving '10.1016/S0006-3207(01)00265-8'. See error detail
#> in results.
#> [[1]]
#> [[1]]$doi
#> [1] "10.1890/09-1641"
#> 
#> [[1]]$error
#> [1] "Error in cr_GET(endpoint = sprintf(\"works/%s/agency\", x), args = list(),  : \n  res$response_headers$`content-type` == \"application/json;charset=UTF-8\" is not TRUE\n"
#> 
#> 
#> [[2]]
#> [[2]]$doi
#> [1] "10.1890/02-5195"
#> 
#> [[2]]$error
#> [1] "Error in cr_GET(endpoint = sprintf(\"works/%s/agency\", x), args = list(),  : \n  res$response_headers$`content-type` == \"application/json;charset=UTF-8\" is not TRUE\n"
#> 
#> 
#> [[3]]
#> [[3]]$doi
#> [1] "10.1016/S0006-3207(01)00265-8"
#> 
#> [[3]]$error
#> [1] "Error in cr_GET(endpoint = sprintf(\"works/%s/agency\", x), args = list(),  : \n  res$response_headers$`content-type` == \"application/json;charset=UTF-8\" is not TRUE\n"

Various other formats and styles of output are available, see ?rcrossref::cr_cn for details.